Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

Lawrence Lee
Lawrence Lee
4,240 Points

Code Challenge: width height and property

Hi,

So I am kind of stuck at step 3, and here is the question:

Currently, the width of the div with the class 'main' is set to 400px, but the padding applied is adding an extra 40 pixels to its total width. Add a property that forces the padding into the width of the div.

I use div as my selector and I typed padding as 40px. I apply this code as the following: box-sizing: border-box;

Then It tells me that my box-sizing property is wrong? Did I reverse something?

Lawrence Lee
Lawrence Lee
4,240 Points

Never mind, I figured it out!

Lawrence, I know you ended up figuring it out, but could you post the answer anyways? I am currently having difficulties with this one as well and others may have the same problem in the future.

Thanks!

3 Answers

Here is the answer, in case anyone else is having difficulties:

div {
  width: 400px;
  box-sizing: border-box; 
}
Lawrence Lee
Lawrence Lee
4,240 Points

Thank you Guil!

By the way, I do have bit of problem with understanding relative and absolute positioning. I know absolute positioning is assign on first position of the ancestor element. Than relative element sets to its normal position. But I do not quite understand how these boxes are stacking on top of each other in a certain arrangement with combination of relative and absolute positioning pseduo element. Could you explain more?

Thanks!

/I used this and it worked/

.main { box-sizing: border-box; }