I want to vertical-align text in select box

前端 未结 16 1327
爱一瞬间的悲伤
爱一瞬间的悲伤 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:07

    I've had the same problem and been working on it for hours. I've finally come up something that works.

    Basically nothing I tried worked in every situation until I positioned a div to replicate the text of the first option over the select box and left the actual first option blank. I used {pointer-events:none;} to let users click through the div.

    HTML

        
    Select an option

    CSS

    .custom-select{position:absolute; left:28px; top:10px; z-index:1; display:block; pointer-events:none;}
    

提交回复
热议问题