2

I'm working on a website, trying to get the basic skeleton of my design to enable me to add content and have it grow the div to the length of the content. My problem is that it seems that as soon as the page loads, it only shows the background color of the div for the initial browser window size.. I'm not doing a very good job explaining; honestly because I'm not sure what the problem is, I just know it isn't working correctly.

Thanks!

bruchowski
  • 5,043
  • 7
  • 30
  • 46

2 Answers2

4

The problem is you have floated elements inside of #fauxcolumns that you're not clearing. The solution is to clear them.

The easiest way is to add overflow:hidden to #fauxcolumns like this:

#fauxcolumns {
    ...
    overflow: hidden;
    ...
}

This question shows other clearing methods if you want to see options: What methods of ‘clearfix’ can I use?

You also don't need to have height:100% on everything, and definitely not on #fauxcolumns as it will clip content that's below the "fold".

Community
  • 1
  • 1
Philip Walton
  • 29,693
  • 16
  • 60
  • 84
2

In #fauxcolumns, you declared height: 100%. Any time elements use a percentage value, it's relative to their container. Thus, setting height: 100% on #fauxcolumns results in a height that is equal to the height of the browser window. That is partially why your div cuts off where it does. Removing height: 100% is the first step towards allowing the height to grow to the size of the content.

The other reason why this doesn't work is because you have floated elements inside #fauxcolumns that you haven't cleared. I don't particularly see any reason why you need them floated in the first place, but if you do, adding overflow: hidden will ensure that your floats are cleared and the container wraps these elements.

To summarize, remove this height: 100% declaration and add overflow: hidden.

Wex
  • 15,539
  • 10
  • 64
  • 107