Background image position

I have a background image whose size is larger than container i want to fit the background image in the container so that the image shoud not be stretched or cut . I am trying to use background position by giving values in percentage but that is not helping what should i do
3 Replies
snxxwyy
snxxwyy2y ago
@.talhamustafa on your container you would do-
background-image: url("path or link to image here");
background-size: cover;
background-image: url("path or link to image here");
background-size: cover;
The background-size: cover; property allows the image to fit in the container without stretching. You can then use background-position to see the parts of the image you need to.
Moni
MoniOP2y ago
I am doing exactly same but some parts of image is showing
Jochem
Jochem2y ago
share your code then, otherwise people are just guessing in the dark. Something like codepen would be best, or hosted on something like github pages #how-to-ask-good-questions

Did you find this page helpful?