Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-29-2012, 12:26 AM   PM User | #1
stevenmw
Regular Coder

 
stevenmw's Avatar
 
Join Date: Jun 2007
Location: OK
Posts: 446
Thanks: 26
Thanked 30 Times in 30 Posts
stevenmw is an unknown quantity at this point
Give a div 100%height of the div it is inside of when container has no fixed height

Let's say i have a div that is 100% wide, but has no fixed height.

Then inside of this div you have two columns with no fixed height, but the left columns is always going to be taller based on content.

What is the best way (if at all possible) to tell the shorter right column to take up 100% of the containers height.

Is this even possible. How can you get 100% of nothing?

Appreciate any help, thanks.
stevenmw is offline   Reply With Quote
Old 09-29-2012, 12:28 AM   PM User | #2
Sammy12
Registered User

 
Join Date: Jun 2011
Posts: 1,063
Thanks: 12
Thanked 241 Times in 240 Posts
Sammy12 is on a distinguished road
You can't unless you used absolute positioning, faux columns, or JavaScript to detect the height of the parent.

Absolute Positioning:

Code:
#container {
    position: relative;
    width: 600px;
}
#short-column {
    position: absolute; top: 0; left: 0;
    width: 300px;
    height: 100%;
}
#long-column {
    margin-left: 300px;
}
Faux Columns:

Code:
#container {
    width: 900px;
    background: #ddd; /* this background will show up for the short-column */
}
#short-column {
    float: left;
    width: 300px;
}
#long-column {
    overflow: hidden;
    background: #fff; /* this background is just masking the parent's background */
}
http://www.alistapart.com/articles/fauxcolumns/

Almost everyone uses faux columns especially Google.

----------------------------

All the solutions: http://css-tricks.com/fluid-width-equal-height-columns/
You can also make the background for your "short-column" a border: http://woorkup.com/2009/10/11/really...eight-columns/ (pretty stupid though)

Last edited by Sammy12; 09-29-2012 at 12:34 AM..
Sammy12 is offline   Reply With Quote
Old 09-30-2012, 12:01 PM   PM User | #3
jamaks
New Coder

 
Join Date: Sep 2012
Location: Scottish Borders
Posts: 36
Thanks: 1
Thanked 9 Times in 9 Posts
jamaks is on a distinguished road
Hi, my personal way of doing what you require is
Code:
#container{width:100%;overflow:hidden;}
#longcolumn{float:left;width:49.5%;overflow:auto;}
#shortcolumn{float:right;width:49.5%;overflow:auto;padding-bottom:20em;margin-bottom:-20em;}
The 20em figure is variable and only has to be enough to cover the difference between the long and short column content difference. The figure used must be the same with padding having a plus value and the margin having a negative value.
If the situation arises where you do not which column would be the shorter then you would give both columns the plus padding - minus margin instruction. Jim
jamaks is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 04:57 PM.


Advertisement
Log in to turn off these ads.