Is it possible to do the same image positioning in the img tag as with background-size: cover ?
I saw solutions using object-fit , also looked at other options, but none of them work. Can I do without object-fit ?
Answer 1, authority 100%
The object-fit property works: most likely you misapplied or looked at it in IE. Below is an example of the correct use of the property:
# bg {
height: 100vh;
width: 100%;
position: relative;
}
#bg img {
object-fit: cover;
height: 100%;
width: 100%;
}
& lt; html & gt;
& lt; body & gt;
& lt; div id = "bg" & gt;
& lt; img src = "https://1000.tech/img/bg0.jpg" & gt;
& lt; / div & gt;
& lt; / body & gt;
& lt; / html & gt;