473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

CSS and Container Height Problems

Hi

I have a div which contains my local navigation bar, which has a blue
background and is next to the content div, at the moment however this
blue background colour stops after the unordered list ?

I would like the background colour to fill the entrire length of the
localnav div

How is this achieved with CSS?
#localnav{
float: left;
min-height: 100%;/* set here min height */
height: auto !important;/* overwrite the height */
height: 100%;/* this is also the min height for IE */
width: 154px;
background-color: #193C65;
text-align: center;
font-family: tahoma,verdana, arial, sans-serif;
font-size: 10px;
font-weight: bold;
color:#FFFFFF;

}

<div id="localnav">
<p class="navblock">Navigation</p>
<img class="navpics" src="image.gif" alt="picture">

<ul>
<li><a href="">Online</a </li>
<li><a href="">Knowledgebase</a </li>
<li><a href="">News</a </li>
<li><a href="">Training</a</li>
</ul>
</div>

Dec 14 '06 #1
3 4448
On 2006-12-14, ia***@aol.com <ia***@aol.comwrote:
Hi

I have a div which contains my local navigation bar, which has a blue
background and is next to the content div, at the moment however this
blue background colour stops after the unordered list ?

I would like the background colour to fill the entrire length of the
localnav div
The background colour of the localnav div does fill the entire height of
the localnav div, by definition. Do you mean you want the localnav div
to be the same height as the content div?

How is the height of the content div determined?
How is this achieved with CSS?
Generally easier with position: absolute than float I think, because you
can just set the bottom of the div to be "0px" from the bottom of its
container, even when the container's height is auto and depends on its
content. But post a more complete example (i.e. one that includes the
content div as well).
min-height: 100%;/* set here min height */
height: auto !important;/* overwrite the height */
height: 100%;/* this is also the min height for IE */
I don't really understand what all this means-- some kind of IE hack?
Dec 14 '06 #2
Thats correct, I would like the navigation div to be the same height as
the content div (whatever that will be from page to page)

The content DIV has no height determined

This is the full code
html,body,wrapper,localnav{
height: 100%;
min-height: 100%
}
body {
margin: 0;
padding: 0;
background-color: #2571B1;
color: white;
background: #2571B1 url(intranetbg1.gif) repeat-x;
font: 12px Arial, Helvetica, Verdana, sans-serif;
}

#wrapper{
background-color: #FFFFFF;
border: 1px solid #000000;
width: 780px;
margin: 0 auto;
text-align: left;
height: 100%;
}

#header{
background-color: #193C65;
height: 64px;
border-bottom: 1px solid #DEDEDE;
width: 780px;
overflow: hidden;
background: url(header-m.jpg) repeat-x 0 0;
}
#content{
float: right;
width: 585px;
background-color: #ffffff;
padding: 20px;
}

#localnav{
float: left;
min-height: 100%;/* set here min height */
height: auto !important;/* overwrite the height */
height: 100%;/* this is also the min height for IE */
width: 154px;
background-color: #193C65;
text-align: center;
font-family: tahoma,verdana, arial, sans-serif;
font-size: 10px;
font-weight: bold;
color:#FFFFFF;

}

<body>
<div id="wrapper">

<div id="header">
Content
</div>

<div id="localnav">
Content
</div>

<div id="content">
Content
</div>

</body>

Dec 15 '06 #3
On 2006-12-15, ia***@aol.com <ia***@aol.comwrote:
Thats correct, I would like the navigation div to be the same height as
the content div (whatever that will be from page to page)

The content DIV has no height determined
See below for a suggestion using positioning.

The way this works is that we have a relatively positioned container for
#localnav and #content.

That container's (auto) height is determined by its normal-flow
descendents, i.e. by #content, since #localnav is absolutely positioned
and therefore not in the normal flow.

But because the container is relatively positioned, it is the containing
block for #localnav. When we give #localnav values for the properties
top, left and bottom, they refer to the containing block, i.e. we are
making #localnav 0px from the top, left and bottom of that containing
block.

So, the containing block's height depends on #content, and #localnav is
wedged into that containing block, 0px from the top and 0px from the
bottom of it, whatever the container's computed height turns out to be.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title>Test Page</title>
<style type="text/css">
#localnav
{
width: 154px;
position: absolute;
border: 1px solid red;
left: 0;
top: 0;
bottom: 0;
}
#content
{
margin-left: 156px;
border: 1px solid green;
}
</style>
</head>
<body>
<div style="position: relative">
<div id="localnav">
links and things links and things links and things links and
things
</div>
<div id="content">
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
content and stuff content and stuff content and stuff
</div>
</div>
</body>
</html>
Dec 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ney André de Mello Zunino | last post by:
Hello. The issue is quite known: you have a block-level container holding a set of floated elements and you need that the container's content height take the floated elements' dimensions into...
6
by: Florian Brucker | last post by:
Here's the code: <html> <head> <title>CSS Test</title> <style> div.container { border-width:1px; border-color:#000; border-style:solid;
7
by: Don G | last post by:
Is it possible to lock the aspect ratio of container using CSS? For example, have a <div> that is resized according to the size of the browser window, but remains square, regardless of it's size....
4
by: wls | last post by:
I've got a problem that requires rendering DIVs at different offset locations, and while I've got a solution that works, the absolute positioning is working to the client window, not to the parent...
1
by: Miked | last post by:
Hello: I'm relatively new to CSS, and I'm doing a site where I don't want to use any tables. I've gotten pretty far, and the site has the layout I want. My only problem is that I'm using the...
2
by: ge5talt | last post by:
Hi all, I am looking for a switch that will style the height of a parent element to a specific % if the height of the contents is less than the height of the container (it doesnt spill out), or...
3
by: Jeffrey Walton | last post by:
Hi All, I have a horizontal Splitter, for which I would like the top panel to remain 20 pixels in height. I do this because I have a containter on it, and I overide the OnPaint method. It is...
3
by: simplicity | last post by:
Is it possible to get / change current dimentions (I am specifically interested in height) of the div container? I have the element or variable height (accordion) that I want to anchor to the...
1
by: anish007 | last post by:
I have a problem with making div container height grow with respect to the other. I have basically 3 div containers, the div container named main contains the other 2 containers left and right...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.