object-fit, object-positioning and absolute positioning
问题 Whilst trying to make an image fit into a rectangle, I came across a weird problem and wondered if anyone knew why these three ways of using object fit act differently: .container { width: 250px; padding-top: 20%; border: 1px solid red; position: relative; display:inline-block } .container>img { position: absolute; top: 0; left: 0; object-fit: contain; object-position: center center; } .image { width: 100%; height: 100%; } .image-1 { right: 0; bottom: 0; } .image-2 { right: 0; bottom: 0; max