Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Forum's 100% div solution doesn't work when div is in a container
Old 08-18-2008, 03:45 AM Forum's 100% div solution doesn't work when div is in a container
Novice Talker

Posts: 10
Trades: 0
http://www.webmaster-talk.com/css-fo...l-browser.html

I'm having a strange problem when assigning 100% height to the html tag.

I have a left float div I want to extend to the bottom of the page that is inside a container div. When I assign 100% height to the html tag IE7 and Firefox cut the container short for some strange reason. If I don't assign a 100% height to the html tag then the chain is broken and the left float div won't extend to the bottom of the page.

So I end up in this odd catch-22 where 100% height to the html tag won't let the container extend to the bottom of the page but not adding it to the html tag won't extend the left float div.

Quote:
<style>


html, body {
top: 0;
left: 0;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}

.window {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background-color: #CCCCCC;
}


.panel_left {
margin: 20px;
padding: 0;
background: #FFFFFF;
border: 1px solid #000000;
width: 215px;
min-height: 100%;
float: left;
}
</style>

Last edited by joshua4; 08-18-2008 at 02:15 PM..
joshua4 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-18-2008, 06:07 AM Re: Forum's 100% div solution doesn't work when div is in a container
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
If you give a 100% height to html and body, they will have the same size as the height of the browser-window. Every element that is longer than this height will break out. A relative height is based on the height of the parent-element, so Firefox and iE 7 handle in the most logical way.

Maybe fixed or absolute positioning will help you but It depends on how you really want it to be.

Code:
.leftbar {
display:block;
position:absolute;
top:0;
left:0;
width:215px;
height:100%;
}

Last edited by bas; 08-18-2008 at 06:08 AM..
bas is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 01:29 PM Re: Forum's 100% div solution doesn't work when div is in a container
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
position:absolute would not be a good solution as it causes some major problems in IE - and it's utterly unnecessary.

The problem is NOT the 100% height rules, the problem is you have not CLEARED your floats... something you MUST do.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 03:41 PM Re: Forum's 100% div solution doesn't work when div is in a container
Novice Talker

Posts: 10
Trades: 0
Quote:
Originally Posted by LadynRed View Post
position:absolute would not be a good solution as it causes some major problems in IE - and it's utterly unnecessary.

The problem is NOT the 100% height rules, the problem is you have not CLEARED your floats... something you MUST do.
But clear the floats how? I need two solutions here:

- Get the container to clear with floated divs inside it
- Get the left float div inside the container to extend to the bottom of the page

Example
http://jglasman.name/test/test.html

I've tried adding "overflow: auto;" to the container and that seems to clear it but then I'm scrolling with the container and not the window. In a complicated web page that would not produce acceptable results. Setting the container to "overflow: hidden;" cuts off the majority of content. Furthermore, even with all these solutions the left float div is still not extending to the bottom of the page.

There seem to be a lot of different solutions to produce these effects but I've yet to find ones that work together for what I'm trying to accomplish.

Last edited by joshua4; 08-18-2008 at 03:44 PM..
joshua4 is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 05:08 PM Re: Forum's 100% div solution doesn't work when div is in a container
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
Simple, add a clearing element just before the closing </div> for #window. I use this method:

.brclear{
clear:both;
height:0;
margin:0;
font-size: 1px;
line-height: 0;
}

Then <br class="brclear" /> in the HTML - works every time - whereas using overflow can have the consequences you described.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 05:28 PM Re: Forum's 100% div solution doesn't work when div is in a container
Novice Talker

Posts: 10
Trades: 0
Quote:
Originally Posted by LadynRed View Post
Simple, add a clearing element just before the closing </div> for #window. I use this method:

.brclear{
clear:both;
height:0;
margin:0;
font-size: 1px;
line-height: 0;
}

Then <br class="brclear" /> in the HTML - works every time - whereas using overflow can have the consequences you described.
that doesn't seem to have had any affect
joshua4 is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 05:34 PM Re: Forum's 100% div solution doesn't work when div is in a container
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
You put the min-height: 100% in the wrong place. Put min-height:100% on .window and just put height: 100% on left panel and it'll work - at least in standards-compliant browsers.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Last edited by LadynRed; 08-18-2008 at 05:47 PM..
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 05:47 PM Re: Forum's 100% div solution doesn't work when div is in a container
Novice Talker

Posts: 10
Trades: 0
FF3 & IE7

After adding the clearing element, the container still doesn't extend to page bottom nor does the inner left float div. See example
joshua4 is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 06:06 PM Re: Forum's 100% div solution doesn't work when div is in a container
Novice Talker

Posts: 10
Trades: 0
Quote:
Originally Posted by LadynRed View Post
You put the min-height: 100% in the wrong place. Put min-height:100% on .window and just put height: 100% on left panel and it'll work - at least in standards-compliant browsers.
I'm not so sure. According to the forum's 100% div solution, in order to get a div to extend to the bottom of the page its parent has to have a solid height assigned to it (and all the parents before them) - height:100%. So if thats the case then it won't work if the div is in a container I also need to extend. Once I apply min-height to a div then the height chain is broken and the subsequent divs won't extend to the bottom of their container (at least with that method). See example updated
joshua4 is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 07:32 PM Re: Forum's 100% div solution doesn't work when div is in a container
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
I think you need to re-read the posted article:
Quote:
Any time you declare a percentage dimension on an element, make sure its parent element has a dimension set on it as well so that the child will have something to base its percentage dimension off of. In the case of our page, this means we need to add 100 percent height to the body element, and, in turn, its parent, the html element. We want them to stretch to fill the viewport so that the container div can do so as well. Add the following rule to the start of your style element:

html, body {
height: 100%;
}

...what most people really want are not pages that fill the browser viewport and then stop, but pages that are at least as long as the browser viewport. That "at least" is a clue that what you really want is not an absolute dimension, but a minimum one.

What is happening is that the container div is obeying your instructions. You told the body and html elements to stretch to be as tall as the viewport. You then told the container div to be exactly as tall as them. Thus, the container div will never extend past the bottom of the viewport. It will stop once it reaches 100 percent height, and any remaining content will simply overflow out of the bottom.

..we would like our container div is to be at least as high as the viewport, but if the content is longer than the viewport, stretch to contain it. Luckily, CSS provides a way for us to do that with the min-height property. Change the height: 100% declaration in the #container rule to min-height: 100%, then save the page and preview in a non-WinIE browser. Now when you scroll down, the green container div will extend past the bounds of the viewport and contain all of its content.
You can artificially stretch things with Javascript. OR, you can use the faux-columns method. Faux columns is easy and does not lead to hair-pulling.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Last edited by LadynRed; 08-18-2008 at 07:43 PM..
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 08:31 PM Re: Forum's 100% div solution doesn't work when div is in a container
Novice Talker

Posts: 10
Trades: 0
Quote:
Originally Posted by LadynRed View Post
I think you need to re-read the posted article:


You can artificially stretch things with Javascript. OR, you can use the faux-columns method. Faux columns is easy and does not lead to hair-pulling.
Blah.

Last edited by joshua4; 08-18-2008 at 08:52 PM..
joshua4 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Forum's 100% div solution doesn't work when div is in a container
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.52538 seconds with 12 queries