I would like to have separate banners for mobile and desktop. I’ve managed to code it, but the mobile image is being cut, which is not what I want. I’d like it to occupy the full height of the display. Could you please help me with this?
This code will make sure that on screens smaller than 750 pixels wide, the banner image will take the full height of the viewport without getting cut off and will maintain its aspect ratio using:
.banner__media {
width: 100%;
height: auto; /* Set height to auto to maintain aspect ratio */
}
@media screen and (max-width: 749px) {
.banner__media {
width: 100%;
height: 100vh; /* Set height to full viewport height */
object-fit: cover; /* Maintain aspect ratio without cropping */
}
}
Thanks for the quick reply! Unfortunately, it didn’t quite do the trick, and now the first desktop image has disappeared. Any chance you could help me out with this?
Please try adding below codes to and see if this works ?
Follow these Steps:
Go to Online Store
Edit Code
Find theme.liquid file
Add the following code just above tag
If you require further help to optimize your store, please don’t hesitate to reach out. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!