SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Sep 2008
    0 Post(s)
    0 Thread(s)

    Crazy problem. By adding CSS float the JS doesn't work.

    This should return the height of the content:

    ...but it doesn't work. If I remove the float:left from the boxes then it works: (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.
    Last edited by paul_wilkins; Oct 6, 2012 at 16:17. Reason: corrected title

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Christchurch, New Zealand
    99 Post(s)
    4 Thread(s)
    Quote Originally Posted by johnsmith153 View Post
    This should return the height of the content:

    ...but it doesn't work.
    It works as designed though, for this is a CSS problem. A float is removed from the normal flow of a page, so a container that has all of its contents floated results in there being nothing that keep the size of the container open.

    This can be resolved by clearing the float, so that the container fully surrounds the floated content too.

    The CSS forum is a good place to get further information about this if required.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Melbourne, AU
    448 Post(s)
    8 Thread(s)
    Yes, the easiest way to force the container to wrap around the floated content is to add

    #content {overflow:hidden;}
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts