How can I show three columns per row?

后端 未结 3 1283
醉酒成梦
醉酒成梦 2020-12-08 12:29

I have been trying to show three columns per row. Is it possible using flexbox?

My current CSS is something like this:

.mainDiv {
    display: flex;
         


        
3条回答
  •  温柔的废话
    2020-12-08 13:27

    Even though the above answer appears to be correct, I wanted to add a (hopefully) more readable example that also stays in 3 columns form at different widths:

    .flex-row-container {
        background: #aaa;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
    }
    .flex-row-container > .flex-row-item {
        flex: 1 1 30%; /*grow | shrink | basis */
        height: 100px;
    }
    
    .flex-row-item {
      background-color: #fff4e6;
      border: 1px solid #f76707;
    }
    1
    2
    3
    4
    5
    6

    Hope this helps someone else.

提交回复
热议问题