Why is the text in this folder not vertically centered in Firefox?

Possible duplicate:
I want to vertically align the text in the select box

In this fiddle, the text in the drop-down list is vertically centered in IE and Chrome ... but not in Firefox, where it is aligned vertically. How to focus it in Firefox without disrupting other browsers?

HTML

<select> <option value="One" selected="selected">Test text one</option> <option value="Two">Test text two</option> <option value="Three">Test text three</option> <option value="Four">Test text four</option> </select> 

CSS

 select { height: 30px; width: 260px; border: 1px solid #A9A3A3; font-family: Verdana,Geneva,sans-serif; font-size: 11px; } 
+4
source share
2 answers

The best way to handle this is not to assign a height for the selection, but to add an addition to match the height of other elements.

+1
source

the problem is the violin. Their iframe will have the minimum required size (at least in Firefox). Try something like

 div { height: 10em; display: table-cell; vertical-align: middle; } 

and put a <div> around your <select> . In a real scenario, you can use height: 100% , absolute positioning, or simply change the attributes of any tag that contains your selection.



first misconfirm your question, here is the answer for horizontal alignment

 body { text-align: center; } 

(or any other tag above <select> )


alternatively add the following

 margin-left:auto; margin-right:auto; 

but in general, it is recommended that you set some values ​​for the body to avoid differences between browsers (e.g. indentation, margins, and text alignment).

0
source

All Articles