Go Back   CodingForums.com > :: Client side development > JavaScript programming

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 10-06-2012, 10:03 PM   PM User | #1
johnsmith153
New Coder

 
Join Date: Mar 2012
Posts: 81
Thanks: 7
Thanked 0 Times in 0 Posts
johnsmith153 is infamous around these parts
Crazy problem. By removing CSS float the JS doesn't work.

The title is wrong and I can't edit it: It should read: "By ADDING CSS float":

This should return the height of the content:

http://page-test.co.uk/float.html

...but it doesn't work. If I remove the float:left from the boxes then it works:

http://page-test.co.uk/no-float.html (this works)

The only difference in the two is that the boxes in the working one do not have float:left.

Why? This is crazy. What can do I do about it?

Thanks for looking at my examples.
johnsmith153 is offline   Reply With Quote
Old 10-06-2012, 11:48 PM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
A parent element that contains only floated elements collapses such that its height is 0. The provided link discusses ways to clear floats.

Adding overflow:auto to the parent element often works to fix this.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 10-07-2012, 07:18 PM   PM User | #3
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,455
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
if the tag around the float:left boxes is changed to float:left, its height comes back.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me 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:15 PM.


Advertisement
Log in to turn off these ads.