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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Snow Fall](https://uploads.teamtreehouse.com/production/profile-photos/2118412/micro__snowFlake.jpeg)
Snow Fall
1,751 PointsConvert padding of a container with 10px that's inside a container with width: 700px I answer 1.4% but wrong! How?!
I convert the padding based on the parent container's width and the answer is stated as wrong. I don't see how or understand why. Assistance is greatly obliged!
<!DOCTYPE html>
<html>
<head>
<style>
/* When setting flexible margin on an element, your context is the width of the element’s container.
When setting flexible padding on an element, your context is the width of the element itself. */
p {
margin: 0;
}
body {
color: #fff;
}
.container, .icing, .cake, .filling {
box-sizing:border-box;
-moz-box-sizing:border-box; /* Firefox */
-webkit-box-sizing:border-box; /* Safari */
}
.container {
max-width: 700px;
}
.icing {
background-color: #B4C34F;
width: 100%; /*700px*/
padding: 10px;
}
.cake {
background-color: #f8748f;
width: 85.714285714%; /*600px*/
margin: 1.428571429%;
padding: 1.428571;
}
.filling {
background-color: #4FB69F;
width: 83.33333333%; /*500px*/
margin: 1.6666666666%;
padding: 10px;
}
</style>
</head>
<body>
<div class="container" id="container">
<div class="icing">
<p>Icing</p>
<div class="cake">
<p>Cake</p>
<div class="filling">
<p>Filling</p>
</div>
</div>
</div>
</div>
</body>
</html>
4 Answers
![Rich Bagley](https://secure.gravatar.com/avatar/3c3fa6acfb194822af9db63ea5c201f4?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Rich Bagley
25,869 PointsHi,
If this is for the cake class it looks to be 600px rather than 700px meaning the value would be 1.6666666666% instead:
.cake {
background-color: #f8748f;
width: 85.714285714%; /*600px*/
margin: 1.428571429%;
padding: 1.6666666666%;
}
Hope that helps
-Rich
![Snow Fall](https://uploads.teamtreehouse.com/production/profile-photos/2118412/micro__snowFlake.jpeg)
Snow Fall
1,751 PointsBTW...I did add the "%" on the padding and it's still stated wrong.
![Snow Fall](https://uploads.teamtreehouse.com/production/profile-photos/2118412/micro__snowFlake.jpeg)
Snow Fall
1,751 PointsOMG!! That worked although I did try 1.6% and it didn't work. At any rate, why did that work? When we convert the margins we use the parent width as the context correct? For example: 10/700 (in the above case).
With that said, we do NOT use the same for padding? Instead we use the current container's width?
Thank you soooo much again. I honestly didn't believe anyone was going to answer, especially not so quickly.
![Rich Bagley](https://secure.gravatar.com/avatar/3c3fa6acfb194822af9db63ea5c201f4?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Rich Bagley
25,869 PointsNo problem. Happy to help.
The challenge is asking: Convert the padding on .cake from pixels to percentages.
So you would focus on the cake class and don't worry about the rest for now.
It says the width of that particular class is 600px in the comment and the padding is set to 10px so 10/600 and then x100 to get the value :)
Hope that helps clear it up a little.
-Rich
![Snow Fall](https://uploads.teamtreehouse.com/production/profile-photos/2118412/micro__snowFlake.jpeg)
Snow Fall
1,751 PointsGreatly. Thank you!