Hey I just found something that works everytime (so far) on mobile and desktop. All you have to do is adjust the height to what looks best. The image stretches in both directions, ignoring aspect, and fills the available space. And isn't hidden by the scroll bars.
If you check out /s/AICreations you can see that the image is stretched way out of aspect, but it still looks ok.
.subbanner {
display: grid;
margin: auto;
position: relative;
height: 12vw;
background-size: 100% 100% !important;
background: url(%%banner%%) no-repeat center;
background-position: top center;
}
.subbannerm {
display: grid;
margin: auto;
position: relative;
height: 12vw;
background-size: 100% 100% !important;
background: url(%%banner%%) no-repeat center;
background-position: top center;
}
Nice. The scroll bar doesn't overlap the background image with that even with the margin at auto?
The scroll bar doesn't overlap the background image with that even with the margin at auto?
No. Both auto and 0px seem to work fine. I tested by setting margin-right to 8px and sure enough there is an 8px black bar next to the scroll bar.
Nice. Glad that is working pretty well then. I made a note of that in case I need to do this with a background image in the future.
(post is archived)