| | |
How do I center extend the nav bar to fit in the body of the page
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2007
Posts: 1
Reputation:
Solved Threads: 0
I'm trying to get my horizontal bar to fit right in middle of my page. It supposed to be 774px wide. I'm also trying to add round (curve) edges to both ends. Here's my css code that I got from a template. Right now, the nav bar is to the left, short and doesn't fit the whole page.
Here's the css
Here's the html file
Here's the css
css Syntax (Toggle Plain Text)
/* NAVIGATION MENU */ #Nav { margin: 0px; height: 27px; background: url(/images/contbg2.gif); } /*New CSS Rules*/ /* CSS Document */ /*Nav Bar CSS rules*/ #nav { margin: 0; padding: 0; height: 27px; float: left; width:100%; /* border: 1px solid #42432d; border-width: 1px 0;*/ } #nav li { display: inline; list-style-type: none; padding: 0; margin: 0; text-align: center; } #nav a, #nav a:link, #nav a:visited { font-size:16px; color:#000; background: url(../images/nav-bg.gif); padding: 3px 16px 6px 16px; float: left; width: auto; border-right:1px solid #ACACE3; text-decoration: none; font: bold 1em/1em Arial, Helvetica, sans-serif; } #nav li:first-child a { border-left: 1px solid #ACACE3; } #nav a:hover, #nav a:active { color:#fff; background: url(../images/nav-hover-1.gif); } /*End of New CSS Rules*/ /* #navLinks { text-align: center; height: 27px; background: url(/images/nav.gif) no-repeat top center; } #navLinks ul { list-style: none; padding: 0; margin: 0; } #navLinks li { float: left; margin: 0 2em; } #navLinks li a { background: url(/images/nav.gif) no-repeat top center; height: 2em; line-height: 2em; float: left; width: 9em; display: block; } #nav a, #nav a:link, #nav a:visited { font-size: 16px; color: #000000; text-decoration: none; padding: 3px 16px 6px 16px; margin: 0px 12px; background: url('/images/nav.gif') no-repeat top center; } #nav a:hover, #nav a:active { background: url(/images/nav-hover.gif) repeat-x top center; color: #fff; }*/ /*#navLeftEnd { height: 27px; background: url(/images/nav-left.gif) no-repeat top left; } #navRightEnd { margin-left: 17px; height: 27px; width: 774px; background: url(/images/nav-right.gif) no-repeat top right; }*/
Here's the html file
HTML and CSS Syntax (Toggle Plain Text)
<body> <div id="container"> <div id="header"> <img src="/images/header.gif" /> </div> <!-- <div id="Nav"> --> <ul id="nav"> <li id="nav-index"><a href="/index.htm">Home</a></li> <li id="nav-products"><a href="/products.htm">Products</a></li> <li id="nav-howitworks"><a href="/howitworks.htm">How It Works</a></li> <li id="nav-faq"><a href="/faq.htm">FAQ</a></li> <li id="nav-partners" ><a href="/partners.htm">Partners</a></li> <li id="nav-about"><a href="/about.htm">About Us</a></li> </ul> <!-- </div> --> </div> </body>
•
•
Join Date: Feb 2005
Posts: 427
Reputation:
Solved Threads: 12
Okay - you have told us what the width should be... any reason you haven't told your css ?

Tell you Nav Container the width you want!
Additionally, you may want to wrappers/contaiers for the nav... once with the full width, one that "shrinks" around the content... then center the shrunk one.
As it's parent has a defined width, it should beable to calcualte a position from there!
please think twice before applying a set height for the nav - as text-resizing will cause the text to break out!
Further, what happens if the text gets bigger in such a short widht.... it could result in the links dropping to two lines not one... in which case it will break your design due to fixed height!
Basically... set widths, not heights!!!

Tell you Nav Container the width you want!
Additionally, you may want to wrappers/contaiers for the nav... once with the full width, one that "shrinks" around the content... then center the shrunk one.
As it's parent has a defined width, it should beable to calcualte a position from there!
please think twice before applying a set height for the nav - as text-resizing will cause the text to break out!
Further, what happens if the text gets bigger in such a short widht.... it could result in the links dropping to two lines not one... in which case it will break your design due to fixed height!
Basically... set widths, not heights!!!
Sometimes life holds wonderful suprises - shame I sleep through them all.
http://www.choose-easyweb.com - Not my design, nor my idea :)
http://www.choose-easyweb.com - Not my design, nor my idea :)
•
•
Join Date: Feb 2005
Posts: 427
Reputation:
Solved Threads: 12
Groovey
Sometimes life holds wonderful suprises - shame I sleep through them all.
http://www.choose-easyweb.com - Not my design, nor my idea :)
http://www.choose-easyweb.com - Not my design, nor my idea :)
![]() |
Similar Threads
- CSS Nav Bar Help needed. (HTML and CSS)
- Why is this page center aligned? (HTML and CSS)
- PLZ Review My Site PLS! (Website Reviews)
- Help needed with floating nav bar css/html (HTML and CSS)
- Please Crit my site Devilsown Alcohol-Injection (Website Reviews)
- Navigation Bar that extends the length of the page (HTML and CSS)
Other Threads in the HTML and CSS Forum
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning problem scroll seo shopping swf swf. textcolor timecolor titletags url urlseparatedwords visualization web webdevelopment webform website windows7





