Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center Select drop down inside div

I'm struggling to centre a select drop-down inside a div. I've tried both margin: auto; and text-align: centre; to no avail

Here is my fiddle http://jsfiddle.net/U8Kja/

Can anyone figure this out? Am I missing something?

Thanks

like image 240
SparrwHawk Avatar asked Jun 16 '12 10:06

SparrwHawk


People also ask

How do I center a dropdown in a div?

Dropdown button can be positioned in the center of the page by setting the “text-align” property of dropdown div to center.

How align object in center in div?

Center Align Elements To horizontally center a block element (like <div>), use margin: auto; Setting the width of the element will prevent it from stretching out to the edges of its container.

How do you center a selected element in HTML?

text-align: center – By setting the value of text-align property of parent div tag to the center. margin: auto – By setting the value of margin property to auto. display: flex – By setting the value of display property to flex and the value of justify-content property to center.

How do I center a div in a table cell?

Use display: table-cell on the child element to make it behave like a <td> elements. Use text-align: center and vertical-align: middle on the child element to center it horizontally and vertically.


1 Answers

Add this to the bottom of your fiddle.

select {
display: block;
margin: 0 auto;
}

The margin auto on right and left side will center a block element within the parent div.

like image 113
Brendan Martin Avatar answered Sep 27 '22 23:09

Brendan Martin