Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firefox not vertically centering select input content with height specified

here's an image of whats going on:

http://imageshack.us/photo/my-images/217/ffbug.png/

here's my code:

select {
    width: 150px;
    height: 40px;
    padding-left: 10px;
}

in chrome and firefox, it vertically-aligns the select values perfectly. in firefox, the values are stuck to the top of the select.

i've tried adding vertical-align: middle and line-height: 40px, both of which changed nothing.

like image 388
scarhand Avatar asked Nov 10 '11 07:11

scarhand


People also ask

How do I center text vertically in HTML?

For vertical alignment, set the parent element's width / height to 100% and add display: table . Then for the child element, change the display to table-cell and add vertical-align: middle . For horizontal centering, you could either add text-align: center to center the text and any other inline children elements.

How do I vertically align text in a div?

Answer: Use the CSS line-height property Suppose you have a div element with the height of 50px and you have placed some link inside the div that you want to align vertically center. The simplest way to do it is — just apply the line-height property with value equal to the height of div which is 50px .

How do I vertically align a div in the middle?

The CSS just sizes the div, vertically center aligns the span by setting the div's line-height equal to its height, and makes the span an inline-block with vertical-align: middle. Then it sets the line-height back to normal for the span, so its contents will flow naturally inside the block.


1 Answers

Just use padding-top: 10px; padding-bottom: 10px; on that element. Your text will be automatically centerd.

like image 172
sascha Avatar answered Nov 09 '22 05:11

sascha