SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2012
    Location
    Tucson, AZ
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Div Acting Weird unless Floated Left

    http://goo.gl/ZciQu

    The #page div is supposed to be centered on the page, however when you remove the "float: left" from the div, it no longer auto-stretches in height. If you view it in Firebug, you will see that without the "float: left", the #page div ends behind the slideshow instead of extending down.

    Any ideas?

  2. #2
    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)
    Remove float: left and add overflow: hidden;

    Code:
    #page {
    text-align: left;
    margin: 0px auto;
    padding: 0;
    width: 900px;
    background: #FDFDFD;
    overflow: hidden;
    }
    The problem is that a div does not automatically wrap around floated content. (By default, floated content hangs out of its container.) Using overflow: hidden is an easy way to force the container (in this case #page) to wrap around the contents.

    Here's a longer explanation: http://pageaffairs.com/web/css/containing-floats/

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2012
    Location
    Tucson, AZ
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ralph, has anyone told you you're awesome lately?

    I normally get rid of the sidebar on my themes, so I never had this issue before. Now it's all making sense. Thanks man!

  4. #4
    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)
    Quote Originally Posted by JeremyEnglert View Post
    Ralph, has anyone told you you're awesome lately?
    Ha ha, a few times, but my wife doesn't believe me.

    Glad that helped.


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
  •