Forum Moderators: not2easy

Message Too Old, No Replies

Centering a list in a DIV block

         

GeeWhizzler

12:54 am on Nov 13, 2005 (gmt 0)

10+ Year Member



Just cant seem to get a list centered vertically in a div block.

#block-box
{
text-align: center;
}

<div id="block-box">
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>

I tried margin: auto auto in the #block-box and it didnt work. I also tried vertical-align middle and it didn't work.

Any suggestions?

Robin_reala

11:00 am on Nov 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Lists are block level elements by default so you need to apply the margin centering to the list itself. For example:

#block-box ul
{
margin: 0 auto;
}

xfinx

11:49 am on Nov 13, 2005 (gmt 0)

10+ Year Member



Robin_reala++ ;-)