I am trying to create a navigation menu similar to that of Stack Overflow (Questions, Tags, Users, Badges, Unanswered, Ask Question).
I tried doing it by having a logo, 5 menu options. These were being placed on top of the container. I can’t align them.
How can I create it so that they are aligned?
HTML:
<body>
<div id="logoimg">
<a href="http://www.domain.com">
<img src="http://www.domain.com/domain.png" border="0"></img>
</a>
</div>
<div id="navi">
<a href="http://www.domain.com/home.php">Home</a>
<a href="http://www.domain.com/profile.php">Profile</a>
<a href="http://www.domain.com/settings.php">Settings</a>
<a href="http://www.domain.com/logout.php">Logout</a>
</div>
<div id="my">
<div id="box">
<div id="pic">
<div id="myname">
<?php echo "$angelinajolie";?>
</div>
</div>
</div>
</body>
CSS:
div#logimg {
margin-left: 213px;
}
#box {
background-color: #FFFFFF;
margin:0 auto;
height: 300px;
width:830px;
border:1px solid #E2E2E2;
}
Give this a shot:
HTML:
Wrap the whole thing in a container div. The logo of the site should probably be an h1 with the title of the site in text (to be friendly to screen readers and the like). The list of links should be unordered lists. That structure will keep things nicely contained and CSS can do the rest.
CSS:
Float the site title/logo and give it a width and height.
Place your logo as a background image on the anchor tag, make the anchor tag a block-level element, hide the text with a text-indent property combined with an overflow of hidden (this shoves the text way to the left).
Float the list elements in the ul tags and give them some styling.
Float the ‘extra’ nav over to the right rather than the left.
See it in action here: http://jsfiddle.net/6F5ky/