Crop image in CSS

后端 未结 8 607
情书的邮戳
情书的邮戳 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 07:57

    You need to put some height to the container also, if not, it doesn't know how much it should show of what it is inside.

    You can try something like this.

    .portrait-crop{
        display: inline-block;
        height: 215px;
        width: 50%;
        overflow: hidden;
    }
    
    
    
    .portrait-crop img{
        width: 100%;
    }
    

提交回复
热议问题