How to vertically align text inside a flexbox?

前端 未结 10 1219
不知归路
不知归路 2020-11-22 09:24

I would like to use flexbox to vertically align some content inside an

  • but not having great success.

    I\'ve checked online and many of the tut

  • 10条回答
    •  渐次进展
      2020-11-22 10:21

      You could change the ul and li displays to table and table-cell. Then, vertical-align would work for you:

      ul {
          height: 20%;
          width: 100%;
          display: table;
      }
      
      li {
          display: table-cell;
          text-align: center;
          vertical-align: middle;
          background: silver;
          width: 100%; 
      }
      

      http://codepen.io/anon/pen/pckvK

    提交回复
    热议问题