How to vertically align text inside a flexbox?

前端 未结 10 1217
不知归路
不知归路 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:27

      It's depend on your li height just call one more thing line height

      * {
        padding: 0;
        margin: 0;
      }
      
      html,
      body {
        height: 100%;
      }
      
      ul {
        height: 100%;
      }
      
      li {
        display: flex;
        justify-content: center;
        align-self: center;
        background: silver;
        width: 100%;
        height:50px;line-height:50px;
      }
      • This is the text

    提交回复
    热议问题