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

前端 未结 3 1948
走了就别回头了
走了就别回头了 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-07 19:10

    The "Inline Blocks" link that Jordan posted is a great resource, particularly when it comes to older browser support. For quick reference for others landing on this page off of google, the basic css for creating a centered, inline-block grid is:

    ul {
        margin: 0 auto;
        text-align: center;
    }
    
    li {
        display: inline-block;
        vertical-align: top;
    }
    

提交回复
热议问题