Web Design and Development Forums

Using a list for navigation, can you center a list?

This is a discussion on "Using a list for navigation, can you center a list?" within the CSS Forum section. This forum, and the thread "Using a list for navigation, can you center a list? are both part of the Design Your Website category.


Go Back   Webforumz.com > Design Your Website > CSS Forum

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old May 5th, 2008, 21:36   #1 (permalink)
New Member
 
Join Date: May 2008
Location: Brighton, England
Age: 23
Posts: 5
Using a list for navigation, can you center a list?

I'm trying to raise my game and stop using tables for layout! I was given the impetus recently to improve my CSS and markup practices (thanks for your comment Welshstew ).

I learnt that using an unordered list, which you make inline, for your navigation bar/links makes sense, and I'm recreating the nav on a site in this way. The only thing is I'm a big fan of centering, and would like to center my navigation bar, but I can't work out how to do it. I can get the list onto one line, but not get the whole line to be centered. I know this is possible, I can see the footer links on http://www.yahoo.com/ are lists that are centred, but can't decipher how they've done it from the massive amount of code that makes their main page.

Any help would be much appreciated.

Tony
tonyb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 5th, 2008, 21:56   #2 (permalink)
 
Join Date: Jun 2007
Location: uk
Posts: 459
Re: Using a list for navigation, can you center a list?

Could you post a link or your code so we can take a look.

Cheers

Pat
dab42pat is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 5th, 2008, 22:05   #3 (permalink)
New Member
 
Join Date: May 2008
Location: Brighton, England
Age: 23
Posts: 5
Re: Using a list for navigation, can you center a list?

Sorry should have done that. Thanks a lot, here you go:

Code: Select all
<div class="nav">
Code: Select all
<ul id="nav">
      <li id="home"><a href="index.html">Home</a></li>
      <li id="paintings"><a href="paintings.html">Paintings</a></li>
      <li id="books"><a href="books.html">Books</a></li>
      <li id="artist"><a href="artist.html">The Artist</a></li>
      <li id="gallery"><a href="gallery.html">Blue Anchor Gallery</a></li>
      <li id="contact"><a href="contact.html">Contact/Ordering</a></li>
  </ul>
</div>
 
body {                 /*part of attempt to center list*/
                text-align: center;
}
div.nav {               /*part of attempt to center list*/ 
                margin-left: auto;
                margin-right: auto;
}
#nav {
                list-style: none;           /*to remove bullet points*/
}
#nav li {
                margin: 0;
                padding: 0;
                float: left;
}
#nav a {
                display: block;
                margin: 0;
                padding: 4px 8px;
                color: #663333;
                text-decoration: none;
                background-color: #FFFFFF;
                font-family: Arial, Helvetica, sans-serif;
                font-weight: bold;
}
#nav a:hover, body#home #home a{
                color: #FFFFFF;
                border-color: #727377;
                background-color: #003300;
                }

Last edited by saltedm8; May 5th, 2008 at 22:11. Reason: added [code] tags
tonyb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 9th, 2008, 16:05   #4 (permalink)
Moderator
 
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,612
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: Using a list for navigation, can you center a list?

You can center the list IF you use display:inline etc... if you float then you can "fake" it my left margin on the first nav item.

if you are using display:inline then ul#nav {text-align:center;} You also may want to consider putting the UL in <div id="nav"> vs using ul id="nav"; just an option.

I would bet that in yahoos footer they are using display:inline;

Yahoo is using:

Code: Select all

<ul id="flist2">
<li class="first"><a href="r/ao">Advertise with Us</a></li>
<li><a href="r/o4">Search Marketing</a></li>
<li><a href="r/pv">Privacy Policy</a></li>
<li><a href="r/ts">Terms of Service</a></li>
<li><a href="r/ad">Suggest a Site</a>[FONT=verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif][/font]</li>
<li><a href="r/ep">Yahoo! Telemundo</a></li
<li><a href="r/1p/*-http://feedback.help.yahoo.com/feedback.php?.src=FP&.from=501&.done=http://www.yahoo.com">Send Feedback</a></li><li class="last"><a href="r/hw">Help</a></li>
</ul>[FONT=verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif]
[/font]
Code: Select all
#footer li{
display:inline;
__________________
Moof! | http://mevans76.com

Last edited by moojoo; May 9th, 2008 at 16:17. Reason: Added yahoo code snippets
moojoo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 9th, 2008, 16:26   #5 (permalink)
New Member
 
Join Date: May 2008
Location: Brighton, England
Age: 23
Posts: 5
Re: Using a list for navigation, can you center a list?

Thank you very much!!!
Yay! I'd been struggling with that, now it's sorted thanks alot.
tonyb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Drop down list - auto select depending on choice from first list ciaranleeper JavaScript Forum 0 Mar 26th, 2008 10:38
List-O-Matic Navigation Creator Jack Franklin CSS Forum 4 Dec 22nd, 2007 12:37
Putting navigation list on top of background image Kurt CSS Forum 5 Sep 16th, 2007 07:19
Spacing between list items incorrect when span tag is used in a list item... MikeTheVike CSS Forum 5 Apr 18th, 2007 01:52
List style / rollover image navigation disappears in IE on the Mac eskymo CSS Forum 5 Mar 1st, 2006 00:43



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 18:16.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59