How to lay-out list items like a grid with CSS and HTML?

前端 未结 3 1992
走了就别回头了
走了就别回头了 2021-02-07 18:56

I have a div block which does not have a fixed width.

Inside, I have an

  • ..
  • block with 11 items. I would like these
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 19:09

    The simplest solution is to use CSS columns:

    http://jsfiddle.net/6tD2D/ (prefixes not included)

    ul {
        columns: 3;
    }
    
    
    • a
    • b
    • c
    • d
    • e
    • f
    • g
    • h
    • i
    • j
    • k

    This will equalize the columns as best it can. However, if there aren't enough elements to be perfectly equal, it will start removing them from the right instead of the center.

提交回复
热议问题