Forum Moderators: not2easy

Message Too Old, No Replies

Width Layout problems.

         

caltobello

8:39 pm on Dec 21, 2007 (gmt 0)

10+ Year Member



Hi. I am new to CSS, and have a display layout that I would like to have for my page.

Essentially I was to have a top section that contain a logo with background color (div = topLogo). I want that follow underneath that on the left with an area for a side menu (div = leftMenu). To the right of the side menu I want a main horizontal menu (div = topMenu). Finally I want an area to place content (div = content).

In the code that follows the background colors have been added just to display my problem. When I set the width of 100% for each area it is only relative to the width of the browser window. So with the topMenu its width is set to the width of the screen. So because it is set to the screen width it causes a horizontal scroll bar to appear.

Here is the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Test CSS</TITLE>

<style type="text/css">
div#container{
width:100%;
height:100%;
margin: 0;
}

div#topLogo{
background-color:#0000FF;
top:0px;
left:0px;
width:100%;
height:50px;
position:absolute;
}

div#leftMenu{
background-color:#FF0000;
top:50px;
left:0px;
width:200px;
height:100%;
position:absolute;
}

div#topMenu{
background-color:#000000;
top:50px;
left:200px;
height:35px;
width:100%;
position:absolute;
}

div#content{
top:120px;
left:220px;
position:absolute;
width:100%;
height:100%;
border-width:thin;
border-color:#000000;
border-style:solid;
}
</style>
</HEAD>
<BODY>
<div id="topLogo">
</div>
<div id="leftMenu">
</div>
<div id="topMenu">
</div>
<div id="content">
</div>
</BODY>
</HTML>

caltobello

8:43 pm on Dec 21, 2007 (gmt 0)

10+ Year Member



If you load this code into a browser you can see what I am talking about. I don't want the page to have any horizontal scroll bars. Just the topLogo, leftMenu, and topMenu colors to go either all the was to the right or bottom.

AlishahNovin

10:57 pm on Dec 21, 2007 (gmt 0)

10+ Year Member



Here's one of the many ways you can do it - though I wouldn't really set things up this way myself, I did it your way, because for all I know your layout may depend on that structure...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Test CSS</TITLE>

<style type="text/css">

html,body {
margin:0px;
height:100%;
}

div#page_container{
position:relative;
width:100%;
height:100%;
}

div#topLogo{
background-color:#0000FF;
width:100%;
height:50px;
position:absolute;
top:0px;
left:0px;
z-index:5;
}

div#leftMenu_container{
position:absolute;
top:0px;
left:0px;
background-color:#FF0000;
width:200px;
height:100%;
z-index:4;
}

div#leftMenu_contents{
margin-top:50px;
background-color:#FF0000;
width:200px;
}

div#topMenu_container{
position:absolute;
top:50px;
left:0px;
background-color:#000000;
width:100%;
height:35px;
color:#ffffff;
z-index:3;
}

div#topMenu_contents{
margin-left:200px;
color:#FFFFFF;
width:200px;
height:100%;
}

div#main_container{
background-color:#00FF00;
width:100%;
height:100%;
position:absolute;
top:0px;
left:0px;
z-index:2;
}

div#main_contents{
margin-top:85px;
margin-left:200px;
}
</style>
</HEAD>
<BODY>
<div id="page_container">
<div id="topLogo">
Logo
</div>
<div id="leftMenu_container">
<div id="leftMenu_contents">
Left Menu Contents
</div>
</div>
<div id="topMenu_container">
<div id="topMenu_contents">
Top Menu Contents
</div>
</div>
<div id="main_container">
<div id="main_contents">
main Contents
</div>
</div>
</div>
</BODY>
</HTML>

caltobello

3:35 pm on Dec 22, 2007 (gmt 0)

10+ Year Member



AlishahNovin: Thanks for the reply!

Since I am new to this, how would you have laid out the page? Maybe your way will work w/my required page layout, and if it doesn't it will teach me an additional way of doing it.
THanks!

caltobello

4:33 pm on Dec 27, 2007 (gmt 0)

10+ Year Member



I finally got a chance to try the solution and this does not work. If you add content to the main content area that requires a vertical scroll bar the color does not continue down the page as you scroll down. I need the left content background color and the main content background color to go throughout the entire page.

thanks for the help in advance.

AlishahNovin

5:30 pm on Dec 27, 2007 (gmt 0)

10+ Year Member



It will work, what you'll need to do is to set the overflow:hidden for the html/body section of the page, and set the overflow:auto for the content container...you may need to do some adjusting here and there, depending on how you want your scrollbars to look.