I want to vertical-align text in select box

前端 未结 16 1329
爱一瞬间的悲伤
爱一瞬间的悲伤 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 01:03

    I stumbled across this set of css properties which seem to vertically align the text in sized select elements in Firefox:

    select
    {
        box-sizing: content-box;
        -moz-box-sizing:content-box;
        -webkit-box-sizing:content-box;
    }
    

    If anything, though, it pushes the text down even farther in IE8. If I set the box-sizing property back to border-box, it at least doesn't make IE8 any worse (and FF still applies the -moz-box-sizing property). It would be nice to find a solution for IE, but I'm not holding my breath.

    Edit: Nix this. It doesn't work after testing. For anyone interested, though, the problem seems to stem from built-in styles in FF's forms.css file affecting input and select elements. The property in question is line-height:normal !important. It cannot be overridden. I've tried. I discovered that if I delete the built-in property in Firebug I get a select element with reasonably vertically-centered text.

提交回复
热议问题