Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

My Portfolio : floating issue.

Need Help on solving issue regarding my floats in the Contact Page. The black background-color you'll see is from the body style. The issue is why is the float goes to my body instead inside of its correct section.

I'm expecting a white background-color from my contact div.

http://w.trhou.se/bxmk1w2pph

4 Answers

Set for contact-contents div overflow:auto, or use clearfix solution. When you use float for child, parent div is collapse (height:0px), because child element out from normal document flow.

I just tested this.

Add this to your CSS:

.clearfix {
  overflow: auto;
}

And add the clearfix class to div where you have the contact-contents ID.

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,254 Points

I'm not sure which element it is you applied the float too but have you tried a clearfix.

.clearfix {
clear: both;
display: table;
content: "";
}

Attach it to the next element in your code and this will return the rest of the document to normal document flow.

Good luck!

Thank you all for the help.

Cheers!