Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center text in a select list

Tags:

html

css

I'm having trouble styling a select list in an html form. Basically I want it to have a font size of 12px, and a height of 30px; The problem is that the box is drawn to the right hight, but the text rendering varies in each browser. In FireFox it renders it in the top left corner. I want to vertically center the text. Anyone know of a way to do this or do I need to make something custom out of a ul?

Thanks

like image 908
Micah Avatar asked Jun 09 '10 02:06

Micah


People also ask

How do I center align text in Dropdownlist?

Dropdown button can be positioned in the center of the page by setting the “text-align” property of dropdown div to center. The following example contains a simple Bootstrap dropdown menu with an added class “my-menu”. The property “text-align: center” is added to the class.

How do you center text in a list in HTML?

To center align an unordered list, you need to use the CSS text align property. In addition to this, you also need to put the unordered list inside the div element. Now, add the style to the div class and use the text-align property with center as its value.


1 Answers

The only way is to drop the <select> and use an <input type="text"< and a <div> to give you the exact feel of a select list but with the ability to do everything as it will be a <li> that you have at the end.

I use this approach not to show aligned text but to use a small icon per each line. This also gives me the ability to show exactly how I want no mater what browser is used as well.

like the image below

enter image description here

like image 176
balexandre Avatar answered Sep 29 '22 07:09

balexandre