Mosaic of images HTML/CSS

后端 未结 10 1321
情书的邮戳
情书的邮戳 2020-11-29 03:53

I want to make an image layout with portrait images inside a div with a fixed aspect ratio of 3:2. The size of images is 327

10条回答
  •  野性不改
    2020-11-29 04:25

    I would like to give simple solution.

    You can simply wrap img tag with DIV. And you should apply CSS to this wrapped DIV.

    Example Code

    Instead of this
    
    
    Use below kind of structure


    CSS

    //  suggestion: target IMG with parent class / ID
    .img_wrapper img{
        width: 100%; 
        height: auto;
    } 
    

    All images inside class .img_wrapper would have proper aspect ratio.

提交回复
热议问题