Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

div alignment

Status
Not open for further replies.

jcostanzo

Programmer
Nov 6, 2007
8
US
Ok I have been working with XHTML and CSS to create a portfolio page.

I created an outer div and then nested in that 3 divs for header nav and content. Here is the page


Now as you can see when the content section gets longer than the nav section the content move to over left. I would like those two things seperate. Here is my CSS coding for the nav

.navigation{
float: left;
clear: both;
padding-right: 25px;
height: 100%;
}

I have removed the height 100% and that does nothing. Should I add a float attribute to the content section?
 
Cheap and dirty options
1. In the nav, add another div with class="clear" and in the the CSS rules for .clear set [green]clear: right;[/green]
2. Don't float the content, but rather give it a margin of the width of the navigation bar.
3. Use a table for layout **NOT RECOMMENDED**

I think I'd opt for option 2.

[plug=shameless]
[/plug]
 
But the width of the navigation is not set. Or are you saying to set the width of the navigation and then set the margin?
 
Ok I think I might have gotten what you meant

.navigation{
float: left;
clear: both;
padding-right: 25px;
width: 150px;
}

.content{
margin-left: 150px;
}

but still did not work
 
Position appears to be working now...

However, I noticed in your code:
Code:
<img src="../images/shim.gif" width="10" height="45" alt="transparent white space" />
This shouldn't be needed, you should use margin and padding to control spacing instead of forcing users to download blank images.

[plug=shameless]
[/plug]
 
Thank you for the tip. I did solve my issue with the margin-left in css.

This is skelton code I will fix soon.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top