CSS vertical alignment text inside li

前端 未结 9 1528
甜味超标
甜味超标 2020-12-07 19:59

I am displaying number of boxes in a row with fix height and width, generated from

  • tags. now I need to align the text in the vertical center. The CSS vertical-a
  • 9条回答
    •  情深已故
      2020-12-07 20:07

      In the future, this problem will be solved by flexbox. Right now the browser support is dismal, but it is supported in one form or another in all current browsers.

      Browser support: http://caniuse.com/flexbox

      .vertically_aligned {
      
          /* older webkit */
          display: -webkit-box;
          -webkit-box-align: center;
          -webkit-justify-content: center;
      
          /* older firefox */
          display: -moz-box;
          -moz-box-align: center;
          -moz-box-pack: center;
      
          /* IE10*/
          display: -ms-flexbox;
          -ms-flex-align: center;
          -ms-flex-pack: center;
      
          /* newer webkit */
          display: -webkit-flex;
          -webkit-align-items: center;
          -webkit-box-pack: center;
      
          /* Standard Form - IE 11+, FF 22+, Chrome 29+, Opera 17+ */
          display: flex;
          align-items: center;
          justify-content: center;
      }
      

      Background on Flexbox: http://css-tricks.com/snippets/css/a-guide-to-flexbox/

    提交回复
    热议问题