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
How do center my nav bar
Old 06-18-2008, 10:24 PM How do center my nav bar
Snot's Avatar
Super Talker

Posts: 132
Name: Chase
Trades: 0
This is the html part of my code and it may be the problem.

Code:
<div id="navblock">
            <ul id="mainNav">
                <li><a href="../../index.php" title="Tarantula Database Home">Home</a></li>
                <li><a href="../pages/search.php" title="Tarantula Database Search">Search</a></li>
                <li><a href="../pages/submit.php" title="Tarantula Database Submit">Submit</a></li>
                <li><a href="index.php" title="Tarantula Database Forum">Forum</a></li>
                <li><a href="../pages/contact.php" title="Tarantula Database Contact">Contact</a></li>
            </ul>
        </div>

With the css code it was floating to the left and looked fine but it wan't centered. it look like like this

http://www.tarantuladatabase.com/this1.JPG

So I changed my css code to this

Code:
  }

 ul#mainNav li{
    border-top: 1px solid #766454;
    border-bottom: 1px solid #766454;
    margin-right: auto;
    margin-left: auto;
  }
And that didnt work either

http://www.tarantuladatabase.com/assets/forum

Any idea how I can center it?
__________________

Please login or register to view this content. Registration is FREE
Snot is offline
Reply With Quote
View Public Profile Visit Snot's homepage!
 
 
Register now for full access!
Old 06-18-2008, 11:23 PM Re: How do center my nav bar
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
May want to have this moved to the CSS forum, since it's a CSS question.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 06-19-2008, 12:06 AM Re: How do center my nav bar
Snot's Avatar
Super Talker

Posts: 132
Name: Chase
Trades: 0
Really? Could you explain that please?

I was thinking the the li tags needed to be changed to in line but how can I do it in css?
__________________

Please login or register to view this content. Registration is FREE
Snot is offline
Reply With Quote
View Public Profile Visit Snot's homepage!
 
Old 06-19-2008, 11:21 AM Re: How do center my nav bar
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
I usually do something like this (I think this is what you're looking for):

Code:
ul#mainNav {
    display: block;
    text-align: center;
}

ul#mainNav li {
    display: inline;
}
And I would probably put the borders on the ul#mainNav, instead of on the child li, so that the borders stretch across the window. That said, the way I have set it up, you can probably just remove the <div id="navblock">, and put whatever styling you need for it on the ul#mainNav, since its display is now block, and it pretty much acts like a div.
__________________
Join me on
Please login or register to view this content. Registration is FREE

Last edited by wayfarer07; 06-19-2008 at 11:25 AM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 06-19-2008, 03:47 PM Re: How do center my nav bar
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
When you float an element, you MUST give that element a width. The margin: 0 auto; can't work because there's no width defined.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How do center my nav bar
 

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.22020 seconds with 12 queries