SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Sep 2008
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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.
    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
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by johnsmith153 View Post
    This should return the height of the content:

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

    ...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.
    http://www.positioniseverything.net/easyclearing.html

    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
    Location
    Melbourne, AU
    Posts
    24,167
    Mentioned
    453 Post(s)
    Tagged
    8 Thread(s)
    Yes, the easiest way to force the container to wrap around the floated content is to add

    Code:
    #content {overflow:hidden;}


Bookmarks

Posting Permissions

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