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

Reply
 
LinkBack Thread Tools Display Modes
Old 03-08-2010, 05:16 AM   #1
New Member
 
Join Date: Feb 2010
Posts: 3
Default auto div heights

Hi,

I need to design where div column adjusts its height with another div.
the design expected:- attached expected.jpg
where left and right sidebar should adjust their height to contents height.


the code


<div id="container2">
<div id="vmenu">
<p>Content for id "vmenu" Goes Here</p>
</div>
<div id="loginmenu">
<?php include("login.php"); ?>
</div>
<div id="content">
<p>Content for id "content" Goes Here</p>
</div>
</div>


.css code

#container2 {
background-color: #FFF;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #999;
border-right-color: #999;
border-bottom-color: #999;
border-left-color: #999;
margin-top: -1px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
white-space: normal;
height: auto;
width: 942px;
display: block;
overflow: auto;
}
#vmenu {
width: 130px;
margin-right: auto;
margin-left: auto;
background-color: #FFF;
padding: 10px;
height:auto;
display: block;
}
#loginmenu {
width: 180px;
margin-right: auto;
margin-left: auto;
background-color: #cccccc;
padding: 10px;
height:auto;
}



......
vmenu - left sidebar
loginmenu - right sidebar
Attached Images
 
abhi4u is offline   Reply With Quote


Old 03-08-2010, 07:40 PM   #2
New Member
 
Join Date: Jan 2010
Location: Edmonton, AB
Posts: 21
Default

use height:100% instead of auto...this should set your left/right menu divs to 100% of their parents...which is your #container2

Please let me know if that worked.
__________________
Regards,

John Scott
Edmonton Web Design And Development
johnscott is offline   Reply With Quote
Old 03-09-2010, 03:33 PM   #3
Super Moderator
 
Join Date: Oct 2008
Location: Arizona, USA
Posts: 1,050
Default

Using 100% height:

When applying 100% height to an element you must also apply it to its parent. If you do not, the child element has no reference as to what 100% is. 100% of what? make sense? What I have done in the past is apply 100% height to the body.

In reference to your column diagram below,
to get the middle div to adjust in height with the left and right divs, place the L/R divs inside the middle one. This way as they grow in height they will push the height of the middle div. You will need to use positioning/floats and overflow in your css.

Let me know if you need help.
__________________
John Darling
Graphic / Web Designer
SmarterTools Inc.
(877) 357-6278
www.smartertools.com
PixelPusher 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 10:38 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.