Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-27-2011, 12:01 PM   PM User | #1
Samuel235
New Coder

 
Join Date: Mar 2011
Posts: 18
Thanks: 1
Thanked 0 Times in 0 Posts
Samuel235 is an unknown quantity at this point
Question HEALP! Vertically center my nav!

Hey guys,

I have a nav which is contained inside of a containing DIV that stretches across 100% of the page with a background. The nav is inside of a div that is inside of the container, the nav DIV will not move with padding/margin, its aligned centeral in the middle but yet wont move vertically....

HTML and CSS below, i just need the NavContainer to be vertically centered inside of the Navcontainer.....

HTML
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <title>BigLampPhotography.co.uk</title>
 <link rel="stylesheet" type="text/css" href="main.css" />
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
 <div id="Navcontainer">
 <div id="Nav">
<ul>
<li><a href="#"><img src="images/navhome.png" alt=""/></a></li>
<li><a href="#"><img src="images/navportraits.png" alt=""/></a></li>
<li><a href="#"><img src="images/navgallery.png" alt=""/></a></li>
<li><a href="#"><img src="images/navcrazy.png" alt=""/></a></li>
<li><a href="#"><img src="images/navcontactus.png" alt=""/></a></li>
<li><a href="#"><img src="images/navsales.png" alt=""/></a></li>
</ul>
 </div><!-- end of #Nav -->
 </div><!-- end of #Navcontainer -->

CSS
Code:
* {
 margin:0;
 padding:0;
}

img {
border:none;
}

body {
}

ul{
list-style-type:none;
font-size: 0px;
}

/***** NAVBAR STYLES *****/

#Navcontainer{
background-image: url("images/navbg.png");
background-repeat: repeat-x;
height: 69px;
text-align:center;
vertical-align: middle;
border: 1px solid red;
}

#Nav {
border: 1px solid red;
width: 902px;
height: 12px;
margin: 0 auto;
text-align: center;
}

#Nav ul {
list-style-type: none;
}

#Nav li {
display:inline;
margin-right: 25px;
}
Samuel235 is offline   Reply With Quote
Old 03-27-2011, 01:41 PM   PM User | #2
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,817
Thanks: 9
Thanked 681 Times in 675 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
Code:
#Nav {
    border: 1px solid red;
    height: 12px;
    margin: 28px auto 0;
    text-align: center;
    width: 902px;
}
If both #Nav and #Navcontainer have fixed heights this should work fine,
SB65 is offline   Reply With Quote
Users who have thanked SB65 for this post:
Samuel235 (03-27-2011)
Old 03-27-2011, 02:37 PM   PM User | #3
Samuel235
New Coder

 
Join Date: Mar 2011
Posts: 18
Thanks: 1
Thanked 0 Times in 0 Posts
Samuel235 is an unknown quantity at this point
Thanks for that Works a charm!
Samuel235 is offline   Reply With Quote
Reply

Bookmarks

Tags
center, css, html, nav, vertical

Jump To Top of Thread


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

Forum Jump


All times are GMT +1. The time now is 06:57 PM.


Advertisement
Log in to turn off these ads.