Crop image in CSS

后端 未结 8 594
情书的邮戳
情书的邮戳 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:22

    One possible solution, using only css without affecting your html code is this:

    /* Fix for portrait */
    .portrait-crop {
         width:50%;
         overflow:hidden;
         height:179px;
         display:inline-block;
     }
     .portrait-crop img {
           width:100%;
           height:auto;
     }
    

    or, adding some div (better solution): http://jsfiddle.net/yoyb9jn7/

提交回复
热议问题