Tagged: x
-
AuthorPosts
-
September 6, 2016 at 11:59 am #1163280
davidferpParticipantHello X Team,
In my site I’ve a couple of sections with greenish background images that do not scale as I want to.
These images are PNG with irregular top and bottom borders that I would like to show. However, when selected as backgrounds they are displayed with widths constrained to the section width and height according to their aspect ratio.
Is there a way to constrain the height of the background image to the section height and let the width according to the image aspect ratio, even if that means that part of the left and right extremes of the image do not show?
I know it is a bit complex, I hope I make sense. Otherwise let me know.
Thank you very much in advance for your patience
September 6, 2016 at 12:01 pm #1163284
davidferpParticipantThis reply has been marked as private.September 6, 2016 at 1:13 pm #1163362
NicoModeratorHi There,
Thanks for writing in.
Please try adding min-height to your section style. eg min-height:200px
Let us know how it goes.
Thanks.
September 6, 2016 at 2:24 pm #1163441
davidferpParticipantHi Nico,
Thank you for your proposal.
I added the style you noted to the first section and of course now the top and bottom borders of the background image are visible, but only because the section is higher. And the background image seems to be stretched beyond the original dimensions, it appears a bit blurry… . Is is possible to dynamically reduce the height of the background image itself for other screen sizes in CSS? (for mobile, the current height of this image in section 1 is not appropriate).
Thanks you!
September 6, 2016 at 4:59 pm #1163579
JadeModeratorHi David,
Please try this code in the custom CSS:
.home #x-section-1, .home #x-section-3 { background-size: contain !important; }Hope this helps.
September 8, 2016 at 12:23 am #1165846
davidferpParticipantHello there,
Thank you for pointing me in the right direction. You guys are awesome!
I’ve been playing around with ‘background-size’ and ‘cover’ is the value that best works for me. Still, for small screens the backgrounds do not show as much as I would like. I think I will end up defining multiple backgrounds for different screen widths and see how it looks.
Thanks for making of X the best supported WP theme around!
September 8, 2016 at 2:33 am #1165963
Rue NelModeratorHello There,
You’re welcome! We’re happy to help you out.
If you need anything else we can help you with, don’t hesitate to open another thread.For more information how background image works, please check this topic: https://community.theme.co/forums/topic/section-background-image-2/#post-691126
Hope this helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1163280 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
