Treehouse: Grow your CSS skills. Land your dream job.

float left makes home page disappear

  • # March 1, 2010 at 1:17 pm

    So I have a float:left on one of my divs and it makes my whole content area disappear in ie7 only. The reason I have a float:left is because I have a negative top margin and without the float, it pushes everything up instead of it covering the top element. Is there an alternative to this? Or is there a way to fix this in ie7?

    The page I am working with is

    Here is my div structure:


    (the element I wanted to cover)

    (the element with the float:left and negative top margin)




    here is my css for topcontent:

    #topcontent {
    padding: 27px 20px 20px 30px;
    margin: -40px 0 25px 10px;
    width: 900px;

    I have tried taking the whole topcontent div out and the page reappears. So its definitely that div thats the problem.

    Any help would be great! Thank you.

    # March 2, 2010 at 5:08 am

    Your have 14 xhtml errors. Try fixing it up and see if the problem continues. Go to , enter your url and click "Check".

    # March 4, 2010 at 4:49 pm

    ok so i fixed all but three very minor errors. its still not there in ie7. i think its because of the float. the float needs to be there for the negative margin to take effect. any ideas?

    # March 4, 2010 at 7:33 pm

    Your code:

    #topcontent { padding: 27px 20px 20px 30px; margin: -40px 0 25px 10px; float:left; height:320px; width: 900px; }

    Take out the ‘float: left’. So it should be:

    #topcontent { padding: 27px 20px 20px 30px; margin: -40px 0 25px 10px; height:320px; width: 900px; }

    As soon as I took that out it worked on IE7.
    (I couldn’t notice anything different, but maybe I’m not looking properly. If you have to have the float: left I would probably create an IE7 only stylesheet and make it "float: none" and do a work around in the css somehow. You seem to have a lot of irrelevant css, I think it creates room for error)

    Here is an example of how some of your code is redundant, also you are actually fighting against yourself with the css:

    #contentbox #content { height:auto; padding: 25px 45px 25px 45px; }
    #contentbox.home #content { height:auto; padding: 25px 45px 25px 45px; overflow:hidden; }

    #sidecol ul.sidebox li.widget ul li a { display:block; padding:12px 15px 12px 15px; text-decoration: none; color:#ccc; }
    #sidecol ul.sidebox li.widget ul li a:hover { color:#fff; background: #1e1e1e; }
    #sidecol ul.sidebox li.widget ul li a { border-top: solid #393939 1px; }

    .dropdown li a { display: block; padding:28px 36px 29px 36px; text-align: center; }
    .dropdown ul li a { display: block; padding: 29px 15px 28px 25px; }

    # March 4, 2010 at 7:57 pm

    in firefox when you take the float:left out, it pushes the content box up into the header. in IE it might not do anything tho. The float left allows the negative margin to work properly.

    As for the unnecessary css, the website is still in the developement stage. I was trying a few things out earlier and forgot to remove the code.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.