One of the problems i have is the more wide the page is, the more image is hidden. To be more clear, i want the whole image to always be visible and stretch or shring when needed. Here’s the code im using
The reason is, it is “contained” within a container that is only 200px high, any wider and it will be vertically cropped and you wanted the whole image visible.
i want the height to be stable but the width always 100% of the page meaning it will sometimes stretch the image. Anyways i found that it can only be achieved with img src and not from css
Of course not, an empty container will have no height unless you specify one via css.
As always, the correct method depends upon context, which we don’t have, presumably this is not going to be an empty web page.
I warn against designing your site before adding content.
You can’t decorate a house that has yet to be built, the paint won’t stick.
You shouldn’t really be stretching images of things that are real life. If its a picture of a person a place or an object then it really needs to maintain its aspect ratio when its is stretched/squashed.
If the image is an abstract decoration then yes you can stretch it but if you are stretching a landscape or a person to fit your screen by stretching or squashing then generally that is considered bad practice and amateurish.
There are odd exceptions where you stretch the image for effect or if perhaps its just something like grass or a field or sky but generally don’t squash real life images without preserving the aspect ratio unless that’s what you meant to do.
Yes of course I wasn’t specifically talking about foreground images but all images in general. The normal criteria for what constitutes a background or foreground image still applies.