I want background image fit with the height of the div, there's a way to do that? background-size:cover;
fit only with the width and height autoscale (I need the opposite effect). Thanks.
Use background-size property to cover the entire viewport The CSS background-size property can have the value of cover . The cover value tells the browser to automatically and proportionally scale the background image's width and height so that they are always equal to, or greater than, the viewport's width/height.
When you work with background images, you may want an image to stretch to fit the page despite the wide range of devices and screen sizes. The best way to stretch an image to fit the background of an element is to use the CSS3 property, for background-size, and set it equal to cover.
If the background-size is auto or auto auto :If the image has both horizontal and vertical intrinsic dimensions, it's rendered at that size. If the image has no intrinsic dimensions and has no intrinsic proportions, it's rendered at the size of the background positioning area.
I know this is an old answer but for others searching for this; in your CSS try:
background-size: auto 100%;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With