Flex-box: Align last row to grid

后端 未结 29 2929
不知归路
不知归路 2020-11-22 02:54

I have a simple flex-box layout with a container like:

.grid {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;
}

29条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 03:15

    This version is best way for blocks with fixed width:

    http://codepen.io/7iomka/pen/oxxeNE

    In other cases - version of dalgard

    http://codepen.io/dalgard/pen/Dbnus

    body {
      padding: 5%;
    }
    
    div {
      overflow: hidden;
      background-color: yellow;
    }
    
    ul {
      display: flex;
      flex-wrap: wrap;
    justify-content:center;
      margin: 0 -4px -4px 0;
      list-style: none;
      padding: 0;
    }
    
    li {
      flex: 1 0 200px;
      height: 200px;
      max-width:200px;
      min-width:200px;
      border-right: 4px solid black;
      border-bottom: 4px solid black;
      background-color: deeppink;
    }
    li:empty {
      height: 0;
      border: none;
    }
    
    *,
    :before,
    :after {
      box-sizing: border-box;
    }
    • a
    • b
    • c
    • d
    • e
    • f
    • g
    • h
    • i
    • j
    • k

提交回复
热议问题