Crop image in CSS

后端 未结 8 595
情书的邮戳
情书的邮戳 2021-01-12 07:23

I\'ve created a two-column grid of images, which works fine with all-landscape images: Link. However, I\'ve added a portrait image that throws off the layout, so I\'d like t

8条回答
  •  不要未来只要你来
    2021-01-12 08:08

    You can use CSS3 to handle this very elegantly in a single div without any extra containers :

    .portrait-crop {
        width: 300px;
        height: 100px;
        background-size: cover;
        background-position: center;
    }

提交回复
热议问题