Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Centering a 3 link inline ul in css?
Old 06-27-2006, 11:08 PM Centering a 3 link inline ul in css?
Experienced Talker

Posts: 45
Trades: 0
Hi All,

My question is how do I best use css to center a set of three horizontal links within an 800px wide div?

The links are contained within an unordered list within the 800px wide div named #top-nav

the css is this...

Code:
#top-nav ul li {
display:inline;
list-style:none;
}
with this as the current html...

HTML Code:
<div id="top-nav">
    <ul>
    <li class="aboutus"><a href="#"> ABOUT US </a></li>
    <li class="portfolio"><a href="#"> PORTFOLIO </a></li>
    <li class="services"><a href="#"> SERVICES </a></li>
    </ul>
</div>
Also, the classes above are only used to call a css background image to replace the text. I have no margins padding or alignment set on the classes aboutus portfolio and services at the moment.

thanks for any help!

(hopefully the solution is a simple one that im overlooking from being tired at the moment.. don't you hate when that happens?)
auron is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-27-2006, 11:37 PM Re: Centering a 3 link inline ul in css?
Experienced Talker

Posts: 45
Trades: 0
ok i got it now.

I made a div called #nav and wrapped it around the ul

then added text-align:center to the css code for the ul.

All fixed now!

(but thanks to anyone that was going to respond.. and let me know if there is a better way to do this. thanks!)
auron is offline
Reply With Quote
View Public Profile
 
Old 06-28-2006, 12:46 AM Re: Centering a 3 link inline ul in css?
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Another way you can center something is to apply a width to it and then in also a margin of auto to the left and right. That should center the element inside of it's containing block. Something like:

#top-nav ul {width:500px; margin:0 auto}

That should center the list inside of the top-nav div. You also need a proper doctype for it to work in IE. Your solution works though so there's probably no reason to switch.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to Centering a 3 link inline ul in css?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15379 seconds with 12 queries