I'm trying to replicate the way these images change on this website when you shrink the screen https://sweetbasilvail.com/
I went ahead and added the css I saw from their site, but it still is just shrinking my image on mobile instead of doing of this site is doing
.hero {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
background-color: #211f1f;
}
img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
background-size: cover;
background-position: center;
}
So I have this image that I want to be the background for my entire home screen, but if I use this code below and shrink it to mobile, it basically squishes the image.
img {
width: 100vw;
height: 100vw;
}
And on mobile it ends up looking like this
If I use the regular responsive css, it shrinks the image and ends up leaving a huge white space below
img {
width: 100%;
height: auto;
}
So I'm not sure how to display an image as the entire background without sacrificing the quality of the image or distorting the way it looks. Is it normal to just have the image shrink on mobile? or is there a proper way when using a full image background?
Note the 2nd image with the giant white space is what the original image is supposed to look like at 100% width;