Click to See Complete Forum and Search --> : Centering a ul...
Neczy
09-28-2004, 07:34 PM
Man, this is making me angry, lol.
Could somoene tell me how to center this ul?
http://neczy.no-ip.com/new/
the top links, the ones going horizontal, how can i center that?
Thanks.
#navlist {
margin: 0;
padding: 0 0 20px 20%;
border-bottom: 1px dashed #eee;
}
#navlist ul, #navlist li {
margin: 0;
padding: 0;
display: inline;
list-style-type: none;
font-size: x-small;
font-family: Arial, Helvetica, sans-serif, sans;
}
#navlist li {
width: 15%;
display: block;
float: left;
}
Cstick
09-28-2004, 08:01 PM
<div align="center">
<ul id="navlist">
<li><a href="#" title="Link 1">Link 1</a></li>
<li><a href="#" title="Link 2">Link 2</a></li>
<li><a href="#" title="Link 3">Link 3</a></li>
<li><a href="#" title="Link 4">Link 4</a></li>
<li><a href="#" title="Link 5">Link 5</a></li>
</ul>
</div>
The ALIGN attribute of the DIV tag is invalid HTML, unless you are using a Transitional DTD. I don't think it's valid XHTML in any version, though I could be wrong. Aside from that, I don't think it would work because his DIVs are being floated.
David Harrison
09-28-2004, 08:43 PM
Try this instead: #navlist {
margin: 0;
padding: 0 0 20px 10px;
border-bottom: 1px dashed #eee;
text-align:center;
}
#navlist ul, #navlist li {
margin: 0;
padding: 0;
display: inline;
list-style-type: none;
font-size: x-small;
font-family: Arial, Helvetica, sans-serif, sans;
}
#navlist a:link, #navlist a:visited {
/* float: left;*/
line-height: 14px;
font-weight: bold;
margin: 0 10px 4px 10px;
text-decoration: none;
color: #999;
}I'm not sure why you're using float since you have set the <li>'s to display:inline.
Neczy
09-28-2004, 10:23 PM
thanks guys! The float left was orignally for an old layout i made, was recycling code and didn't notice it. Thanks again, the text-align: center worked perfectly!
David Harrison
09-28-2004, 10:26 PM
Happy to help. :)
Cstick
09-28-2004, 10:44 PM
Jona,
You're probably right about it not meeting standard or at least not being good practice. I didn't even notice that the listitems were being floated either. :)
No problem, Cstick; we all get corrected all the time. In fact... Thanks, Lavalamp, for correcting me. ;) I should have looked more closely.