I want to vertical-align text in select box

前端 未结 16 1325
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 00:25

I want to vertically align the text in select box. I tried using

select{
   verticle-align:middle;
}

however it does not work in any brows

16条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 01:27

    The nearest general solution i know uses box-align property, as described here. Working example is here (i can test it only on Chrome, believe that has equivalent for other browsers too).

    CSS:

    select{
      display:-webkit-box;
      display:-moz-box;
      display:box;
      height: 30px;;
    }
    select:nth-child(1){
      -webkit-box-align:start;
      -moz-box-align:start;
      box-align:start;
    }
    select:nth-child(2){
      -webkit-box-align:center;
      -moz-box-align:center;
      box-align:center;
    }
    select:nth-child(3){
      -webkit-box-align:end;
      -moz-box-align:end;
      box-align:end;
    }
    

提交回复
热议问题