Web Design Forum  
 
Go Back   Web Design Forum > Web and Graphic Design > Web Design

Reply
 
LinkBack Thread Tools Display Modes
Old 05-30-2009, 03:59 AM   #1
Silver Member
 
AusQB's Avatar
 
Join Date: Jul 2008
Location: Perth, Australia
Posts: 167
Send a message via AIM to AusQB Send a message via MSN to AusQB Send a message via Skype™ to AusQB
Default Div height not setting to 100%

I have a fairly basic layout with a left hand side bar for navigation. I've set the height of the side bar to 100% (of the body div) yet it reduces the height to fit the containing div. Within the leftnav div is another div which contains the list.

In other words, I want div#leftnav to fit the height of div#body.

It seems like such a trivial problem but I can't figure it out.

Here is the code, omitting most of the content and irrelevant attributes:

Code:
div#wrap {
	height: auto;
	margin: 10px auto;
	width: 900px;
}

div#header {
	height: 120px;
	width: 100%;
}

div#body {
	height: auto;
	margin-top: 10px;
	width: 100%;
}

div#leftnav {
	float: left;
	height: 100%;
	width: 148px;	
}

div#content {
	float: left;
	height: auto;
	min-height: 600px;
	width: 750px;
}

div#footer {
	float: left;
	height: 60px;
	margin-bottom: 10px;
	margin-top: 10px;
	width: 100%
}
HTML Code:
<body>

    <div id="wrap">
	
	<div id="header"></div>
	
	<div id="body">
	
	    <div id="leftnav"></div>

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

	</div>
	
	<div id="footer"></div>

    </div>

</body>


EDIT: Ok, I realized that setting the height to 100% will not work if the parent element's height is set to auto. Is there a way around this if I don't want a fixed height for the body div?
__________________
RGG Web Designs

Last edited by AusQB; 05-30-2009 at 04:13 AM.
AusQB is offline   Reply With Quote


Old 05-30-2009, 10:50 AM   #2
Gold Member
 
conor's Avatar
 
Join Date: Oct 2008
Location: Ireland
Posts: 349
Default

No.

Not with HTML anyway. As far as I know it is possible in DHTML, or you could try jQuery, although I don't know how to do it myself.
__________________
Conor
conor is offline   Reply With Quote
Old 05-30-2009, 04:08 PM   #3
New Member
 
Join Date: May 2009
Posts: 11
Default

I hope I understand you correctly - you want to have a sidebar that has different background graphic or color than the content area, and always reaches down to the footer regardless of how much content is actually in the sidebar?

If this is what you are trying to do, you could make a faux column by applying a background graphic to div#body. You could make a 900px wide image (only needs to be a couple pixels high), with a 148px wide bar of color on the left that you want for your sidebar, with just transparent pixels on the right. Set that as the background image for div#body and tell it to repeat vertically.

I hope that is what you are trying to do and that my explanation made sense.
jvnderwe is offline   Reply With Quote
Old 05-31-2009, 02:40 AM   #4
Silver Member
 
AusQB's Avatar
 
Join Date: Jul 2008
Location: Perth, Australia
Posts: 167
Send a message via AIM to AusQB Send a message via MSN to AusQB Send a message via Skype™ to AusQB
Default

Quote:
Originally Posted by jvnderwe View Post
I hope I understand you correctly - you want to have a sidebar that has different background graphic or color than the content area, and always reaches down to the footer regardless of how much content is actually in the sidebar?

If this is what you are trying to do, you could make a faux column by applying a background graphic to div#body. You could make a 900px wide image (only needs to be a couple pixels high), with a 148px wide bar of color on the left that you want for your sidebar, with just transparent pixels on the right. Set that as the background image for div#body and tell it to repeat vertically.

I hope that is what you are trying to do and that my explanation made sense.
Yeah I think that might be the best option. It just confounds me that height:100% doesn't parse height:auto as an actual value.
__________________
RGG Web Designs
AusQB is offline   Reply With Quote
Old 05-31-2009, 04:35 AM   #5
Silver Member
 
adamblan's Avatar
 
Join Date: Aug 2008
Location: Lake Tahoe
Posts: 235
Default

Quote:
Originally Posted by conor View Post
Not with HTML anyway. As far as I know it is possible in DHTML, or you could try jQuery, although I don't know how to do it myself.
Yes, javascript provides the most eloquent solution to this problem
__________________
<ablank.us>
adamblan is offline   Reply With Quote


Old 05-31-2009, 04:51 AM   #6
Silver Member
 
AusQB's Avatar
 
Join Date: Jul 2008
Location: Perth, Australia
Posts: 167
Send a message via AIM to AusQB Send a message via MSN to AusQB Send a message via Skype™ to AusQB
Default

Quote:
Originally Posted by adamblan View Post
Thanks for that. I'm a little lost though, where do I put the call statement?
__________________
RGG Web Designs
AusQB is offline   Reply With Quote
Old 06-02-2009, 09:07 PM   #7
Silver Member
 
adamblan's Avatar
 
Join Date: Aug 2008
Location: Lake Tahoe
Posts: 235
Default

you can call the <script> tag anywhere in the document, most often in the <head> section, but pages will load faster if you call scripts toward the end of the page, just before closing your <body>
__________________
<ablank.us>
adamblan is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:15 AM.


Camera Forum - Computer Forum - Web Design Forum

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.