CSS: Ignoring divs height when floating

后端 未结 3 870
灰色年华
灰色年华 2021-02-14 04:39

I\'m trying to display some pictures. All of them have the same width but different height. I\'m trying to do something like:

3条回答
  •  再見小時候
    2021-02-14 05:08

    You can do this with no extra markup with CSS3 column-count, assuming you at least have a single containing element.

    Demo: http://jsfiddle.net/ThinkingStiff/NcxPr/

    HTML:

    CSS:

    #container {
        column-count: 3;
        column-fill: balance;
        column-gap: 10px;
        width: 330px;
    }
    
    .image { 
        display: block;
        margin-bottom: 10px;
        width: 100px;
    } 
    

    Output:

    enter image description here

提交回复
热议问题