likuid.silence
12-26-2008, 08:15 PM
I'm having difficulty centering a horizontal css nav bar I created earlier today. The navigational bar appears on the left all the time. How can I center it? Any help is much appreaciated.
The CSS:
html{
font-size: 100%;
}
body{
font-size: 1em;
font-family: georgia, serif;
text-align: center;
color: #444;
background: #e6e6e6;
padding: 0;
margin: 0;
}
#wrap{
width: 48.56em;
margin: 1.5em auto;
border: 0.063em solid #ccc;
background: #fff;
text-align: left;
}
.oneColElsCtr #container {
width: 47.9em;
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
}
.oneColElsCtr #mainContent {
padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
#nav {
margin: 0;
padding: 0;
background: #6F6146;
list-style-type: none;
width: 767px;
float: left; /* Contain floated list items */
}
#nav li {
margin: 0;
padding: 0;
float: left;
}
#nav a {
float: left;
width: 127px;
color: #FFF;
text-decoration: none;
line-height: 2.5;
text-align: center;
border-right: 1px solid #FFF;
background: url(/images/tab.gif) no-repeat;
}
#nav #nav_con a {
border: none;
}
#nav a:hover {
background-color: #4F4532;
background-position: -127px 0;
}
#body_hom #nav_hom a, #body_com #nav_com a,#body_gal #nav_gal a,#body_sto #nav_sto a,#body_ser #nav_ser a,#body_con #nav_con a {
background-color: #BEB06F;
background-position: -254px 0;
color: #1A1303;
font-weight: bold;
}
img.center {
display: block;
margin-left: auto;
margin-right: auto;
}
My HTML :
<div id="container">
<div>
<ul id="nav">
<li id="nav_hom"><a href="/">Home</a></li>
<li id="nav_jou"><a href="/stones/">Stones</a></li>
<li id="nav_his"><a href="/gallery/">Gallery</a></li>
<li id="nav_ref"><a href="/services/">Services</a></li>
<li id="nav_lin"><a href="/links/">Links</a></li>
<li id="nav_con"><a href="/contact/">Contact</a></li>
</ul>
</div>
.......
</div>
Any ideas?? Thanks.
The CSS:
html{
font-size: 100%;
}
body{
font-size: 1em;
font-family: georgia, serif;
text-align: center;
color: #444;
background: #e6e6e6;
padding: 0;
margin: 0;
}
#wrap{
width: 48.56em;
margin: 1.5em auto;
border: 0.063em solid #ccc;
background: #fff;
text-align: left;
}
.oneColElsCtr #container {
width: 47.9em;
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
}
.oneColElsCtr #mainContent {
padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
#nav {
margin: 0;
padding: 0;
background: #6F6146;
list-style-type: none;
width: 767px;
float: left; /* Contain floated list items */
}
#nav li {
margin: 0;
padding: 0;
float: left;
}
#nav a {
float: left;
width: 127px;
color: #FFF;
text-decoration: none;
line-height: 2.5;
text-align: center;
border-right: 1px solid #FFF;
background: url(/images/tab.gif) no-repeat;
}
#nav #nav_con a {
border: none;
}
#nav a:hover {
background-color: #4F4532;
background-position: -127px 0;
}
#body_hom #nav_hom a, #body_com #nav_com a,#body_gal #nav_gal a,#body_sto #nav_sto a,#body_ser #nav_ser a,#body_con #nav_con a {
background-color: #BEB06F;
background-position: -254px 0;
color: #1A1303;
font-weight: bold;
}
img.center {
display: block;
margin-left: auto;
margin-right: auto;
}
My HTML :
<div id="container">
<div>
<ul id="nav">
<li id="nav_hom"><a href="/">Home</a></li>
<li id="nav_jou"><a href="/stones/">Stones</a></li>
<li id="nav_his"><a href="/gallery/">Gallery</a></li>
<li id="nav_ref"><a href="/services/">Services</a></li>
<li id="nav_lin"><a href="/links/">Links</a></li>
<li id="nav_con"><a href="/contact/">Contact</a></li>
</ul>
</div>
.......
</div>
Any ideas?? Thanks.