Is it possible to ignore the aspect ratio of the image and make the image "fit" to the available space?
Are you wanting the background image to always be fully visible vertically, but horizontally it would scale and stretch to fill the element up to but not behind the scrollbar?
Are you wanting the background image to always be fully visible vertically, but horizontally it would scale and stretch to fill the element up to but not behind the scrollbar?
Yes. Can I do background-size: cover 100% !important;
?
I can't test right now I just got IP banned on my wifi. Too many refreshes too fast testing out CSS. I don't wanna push it on my mobile IP until AOU unblocks my home IP.
Hey. One thing I just tested on GPL that also looked ok for me on desktop:
- leaving your height at
10vh
- changing background-size to
background-size: 100% 20vh !important;
- changing your margin to
margin: 0 8px 0 0 !important;
This allows the image to:
- be 100% width and go behind the scrollbar
- the margin of 8 pixels on the right shifts the background to the left 8px so the scrollbar doesn't overlap it
- the height stretched vertically to fill the 10vh size of the banner element
Didn't check on mobile to see how it looks (might need some margin adjustment to match scrollbar width).
(post is archived)