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 CSS Basics (2014) Basic Layout Floats

Methee Saengow
Methee Saengow
5,474 Points

About the floated divs' width actual size do not match with the size of 46.5%

About the floated divs' width actual size do not match with the size of 46.5% Hi, in the video we have specified the size of the floated .resort and .tips classes to be 46.5%

The .resort and .tips classes both have the same div parent with the class named .secondary-content in which the max-width had been prior specified at 960px.

The floated. resort and .tips classes take up the space of 46.5% of the 960px of the parent div. Then it means the size of each floated should be 446.4px but i use the chrome to inspect the 2 floated elements and found that the width of each floated div is only 399.9 px.

Just would like to have some guidance from friends or teacher here:

Are the width specify to both .resort and .tips relative to div with the class "secondary-content" ? Why the width of both floated divs are 399.9px not 446.4 ? It seems both floated divs have margin to each other which may make the width not 446.4px I am very new to css and web design, please help me

Methee S.

1 Answer

Steven Parker
Steven Parker
231,269 Points

Just because the max-width has been specified doesn't guarantee that the parent is that size, some other constraints might be making it smaller. Did you check that?

And to facilitate a complete analysis, make a snapshot of your workspace and post the link to it here.

Methee Saengow
Methee Saengow
5,474 Points

Steven Parker Thank you very much for your comment !!

I have made a snap shot and the link to my snapshot is provided below: https://w.trhou.se/79xewuj0je

Thanks a lot

Methee S.

Steven Parker
Steven Parker
231,269 Points

Since "box-sizing: border-box" is being set for all elements (line 4 of "style.css"), the 960px max-width setting applies to the outside of the .secondary-content container. And since it has 50px padding on both sides, that reduces the available content area to 860px.

Then, 46.5% of that content area is 399.9px, which is the value you are getting.