Firefox and 100% height problem

This is a discussion on "Firefox and 100% height problem" within the Web Page Design section. This forum, and the thread "Firefox and 100% height problem are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 24th, 2006, 10:03
New Member
Join Date: Sep 2006
Location: London
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Firefox and 100% height problem

Well I'm a newbie to CSS and I have an issue with using 100% height when viewed in Firefox.

IE renders the page as I wish, and the blue background holds all the yellow blocks. Firefox does something weird and the yellow boxes overlap the blue background. If I use a pixel measurement, everything works well. That's great, but I don't want to keep changing the px height of the page each time I add new content.

I uploaded it to my site: http://www.realbabyguide.co.uk/test.html

Any ideas? I'm tearing my hair out (what's left of it!).

Maybe I should have stuck with tables...
Reply With Quote

  #2 (permalink)  
Old Sep 24th, 2006, 12:34
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,730
Blog Entries: 1
Thanks: 0
Thanked 16 Times in 16 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: Firefox and 100% height problem

If the yellow blocks are floated then in this case FF is handling the layout correctly and IE is handling it incorrectly. What you need is a "clearing" div or similar to keep the blue box below the yellow boxes despite amount of content.

.clearing {
height:0;
clear:both;
}

<div class="container">

<div class="block">Here is a test floated block</div>
<div class="block">Here is a test floated block</div>
<div class="block">Here is a test floated block</div>

<div class="block">Here is a test floated block</div>
<div class="block">Here is a test floated block</div>
<div class="block">Here is a test floated block</div>

<div class="clearing">&nbsp;</div>
</div><!--Close COntainer DIV -->
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Reply With Quote
  #3 (permalink)  
Old Sep 24th, 2006, 12:57
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,619
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Firefox and 100% height problem

This is the IE hack I use:

.Clear{width:100%;display:inline-block;clear:both!important}
.Clear:after{content:".";display:block;height:0;cl ear:both;visibility:hidden}
* html .Clear{height:1%}/* Only IE obeys this line */

I know it may be a bit longer than needed but I prefer to be sure....
Simply apply the class 'Clear' to a div so both IE and FF will display what's expected.
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #4 (permalink)  
Old Sep 24th, 2006, 14:29
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,730
Blog Entries: 1
Thanks: 0
Thanked 16 Times in 16 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: Firefox and 100% height problem

Even just clear:both would work in most cases, the problem with the holly hack is IE 7 won't read it I don't think.
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)

Last edited by moojoo; Sep 27th, 2006 at 13:10.
Reply With Quote
  #5 (permalink)  
Old Sep 24th, 2006, 20:51
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Firefox and 100% height problem

Now here's an anarchic thought - IE is doing it right.

Why do I say that?

You need to have Firefox with the web deveopers toolbar to see what I'm getting at.

If you look at the page in Firefox and select Outline Current Element and position the cross-hairs appropriately, you will see that it shows the div as wrapped around the floated boxes.

That blue band at the top is the 80px bottom padding.

IE on the other hand wraps around the boxes, including the bottom margin of the second row and adds the 80px bottom padding after that.

Ergo - IE is doing exactly what you might reasonably expect and Firefox is making a fist of it!

Because everything inside the container div is floated, adding the clearing div still won't make it right.
Reply With Quote
  #6 (permalink)  
Old Sep 26th, 2006, 11:08
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,619
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Firefox and 100% height problem

and so the fight goes on...
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #7 (permalink)  
Old Sep 27th, 2006, 11:13
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Firefox and 100% height problem

I usually do one of these:

Code: Select all
.clear {
    width: 100%;
    height: 1px;
    margin: 0 0 -1px 0;
    clear: both;
}
Seems less messy than yours, spinal. Unless I'm missing some advantage with the hack..?
Reply With Quote
  #8 (permalink)  
Old Sep 27th, 2006, 12:39
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,619
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Firefox and 100% height problem

some browsers won't expand the box to show its content so if you say height:1px it literally means height:1px.

Internet explorer always expands the box to display its content, but the float bug (and some other) happen when a height hasn't been defined.

I'll go through it line by line...

This is the general idea, which we're all using...
.Clear{width:100%;display:inline-block;clear:both!important}
Unfortunatelly, it doesn't always work (as you'd expect).

This is for browsers that accept the :after selector. Just to make sure, it adds an element that will clear on both sides. I haven't needed this per se, but some geeks said some browsers do. don't argue with them...
.Clear:after{content:".";display:block;height:0;cl ear:both;visibility:hidden}

Finally, this line is only understood by IE. It's the safety net to work around the IE box-model bugs. Other browsers ignore it so its no harm...
* html .Clear{height:1%}/* Only IE obeys this line */

I compiled those 3 lines based on this information:
http://www.positioniseverything.net/explorer.html

Because of this:
http://www.webforumz.com/html-forum/...ird-ie-bug.htm
http://www.webforumz.com/css-forum/6...blem-in-ie.htm
http://www.webforumz.com/css-forum/2...ng-borders.htm

To sum up, with those 3 lines I am sure that the browsers will display things what I want, how I want and where I want them.
At least until Microsoft decide to screw it up!
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #9 (permalink)  
Old Sep 27th, 2006, 23:27
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Firefox and 100% height problem

I wish I had IE at hand to test on. I've never had problems before with that code, however. The height of it, 1px, is then offset by a -1px bottom margin so that one pixel is essentially non-existent.

When I do test in IE, I run through IE 5, 5.5, and 6.

I'm a little bit, okay, extremely confused by your last post. I looked at all those links, and I didn't see anything that suggested the code I posted wouldn't work flawlessly. If I could get you to elaborate some more, I'd like to understand your method.
Reply With Quote
  #10 (permalink)  
Old Sep 28th, 2006, 11:45
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,619
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Firefox and 100% height problem

I wish I could elaborate... But I'm no expert!

I see your solution makes perfect sense... And it probably has the same effects.
The thing is, you only know for sure if it works when you come across a certain bug.

You may not have come across this Mozilla bug:
http://www.cs.hmc.edu/~mbrubeck/clear-after/

I had several bugs with floating elements in the last few months so I found every solution to the problems and compiled them into one.

What are your specs? Win/mac?
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #11 (permalink)  
Old Sep 28th, 2006, 12:11
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Firefox and 100% height problem

monkey - the Mozilla fanboys would claim Foxfire was doing it right if it turned your yellow squares into pictures of Hillary Clinton's bum.

This is one of the big pains using FF, you just have to set ".clear: clear: both;" in any stylesheet and be ready to use it. The FF trick I really love is when the containing div turns 1px high and pops up to the very top of the page. appears above the main containter.

IE6 has plenty of problems and theoretically a lot more individual instances of non=compliance with w3c, but as a practical matter IE is just as easy to code for.

The one big advantage writing css for FF is, IMO, an add-on called Aardvark.
Reply With Quote
  #12 (permalink)  
Old Sep 28th, 2006, 12:31
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,730
Blog Entries: 1
Thanks: 0
Thanked 16 Times in 16 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: Firefox and 100% height problem

FF is much more lax on things than the others. Firefox will let you get away with css errors and such while Safari and others are more strict. This is both good and bad. but I will tell you just a simple .clear {height:0; clear:both;} put in the right spot will work wonders. I use it often and it works in everything.
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Reply With Quote
  #13 (permalink)  
Old Sep 29th, 2006, 11:14
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Firefox and 100% height problem

I've used my clear class in many sites and have never had a problem with it. However, there are so many things that CSS depends on to render everything correctly, it may be that by chance other elements were placed in such a way that they got a layout to render correctly. To be frank, I am a firm believer that hacks are a means to cheat the proper use of CSS. In all my test sites and work projects, I haven't seen one situation where I couldn't come up with an alternative stylesheet to compensate for the differences in every major browser. Hacks may be easy, but it won't assure you that your site will look good when another browser release is available six months from now.

Er. Back to the topic monkey64 started, height is a rather ambiguous property when it comes to various browsers. There is no sure-fire way to get exactly the same results in every browser when it comes to percentages. Only using other CSS properties (specifically, clear), will you be able to work it out.
Reply With Quote
  #14 (permalink)  
Old Sep 29th, 2006, 12:06
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,619
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Firefox and 100% height problem

well put ryan, agree with you 100%...
but these hacks aren't invalid CSS. I think they're simply 'tweaks' that don't actually serve any purpose to the layout other than making the browser understand it and render it properly...

there's no harm in that, specially if it reassuers you that you will get the desired output...
a bug that hasn't yet affected you could at any time because, as you said, there are so many factors involved.
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #15 (permalink)  
Old Sep 29th, 2006, 12:43
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,730
Blog Entries: 1
Thanks: 0
Thanked 16 Times in 16 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: Firefox and 100% height problem

http://www.themaninblue.com/experiment/footerStickAlt/
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Reply With Quote
  #16 (permalink)  
Old Sep 29th, 2006, 15:44
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Firefox and 100% height problem

If you look at the code behind maninblue's pages and see thow many divs he uses and the way he has his divs laid out there's nothing very clever going on there at all. IMO
Reply With Quote
  #17 (permalink)  
Old Sep 29th, 2006, 16:01
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,730
Blog Entries: 1
Thanks: 0
Thanked 16 Times in 16 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: Firefox and 100% height problem

It is all about the footer stick man, nothing more.
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Reply With Quote
  #18 (permalink)  
Old Sep 29th, 2006, 23:09
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Firefox and 100% height problem

As you say, nothing clever about it, it's more what you'd call a "hard work" layout. Still it takes a good idea and a lot of pixel-pushing, and it looks great.
Reply With Quote
Reply

Tags
css height, firefox

Thread Tools

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS Div height problem dryjoy Web Page Design 1 Jan 6th, 2008 18:05
Background height problem in FireFox but work in IE EthanCote Web Page Design 6 Mar 16th, 2007 22:59
Height problem frinkky Web Page Design 2 Jan 16th, 2007 15:14
solution to IE7 min-height problem? edd_jedi Web Page Design 10 Nov 21st, 2006 11:11
css problem - div height edd_jedi Web Page Design 3 Aug 30th, 2006 19:38


All times are GMT. The time now is 04:06.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43