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!
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

Convert the padding on .cake from pixels to percentages.
Doesn't work, it supposed to be padding: 1.4285714285714285%; but it doesnt pass the test.
16 Answers

Rick Rakin
6,531 PointsThis is still inconsistent. The second video, "Creating Flexible Margins" teaches converting the margins from px to %. Padding is not discussed. The third and final video, "Scalable Images" teaches about scaling images. Padding is not discussed. The final code challenge tests on padding.

Angela Fonteboa
2,267 Pointsi used the the .cake width percentage and got it to work.

Lexxie Lynn
2,920 Points.. This isn't taught anywhere in the videos, it actually irritates me that this is still a problem and I'm seeing constant inconsistencies in the lessons. Not sure I'm going to keep my Gold membership if they can't fix a small problem like this after 9 months. I did find a solution however after messing with it, I had to add the original padding of 10px to the width of 600px for the width of .cake for a total context of 610px ... then I did 10px / 610 px = 1.63934426229508%
Update: On the VERY NEXT PROBLEM it's not the same equation :/ - In .filling I had to use a context of JUST the width "500px" without the padding of "10px" to divide. Now I'm just confused, they are two different formulas..which one is right..and why has no one fixed this?

i found the correct answer
When setting ?exible padding on an element, your context is the width of the element itself.

Robert Cate
7,911 PointsAlejandro,
Double check, I struggled with this for a bit but you need to make sure you are using the correct formula and variables.
Good luck!
Rob

James Barnett
39,199 PointsAlejandro -
If you are still having trouble, please post ...
- a link to the code challenge you are working on.
- the step of the code challenge you are having issues with
- a "working" example using codepen.io or something similar

Angela Fonteboa
2,267 PointsI am having the same issue. I ame not sure what variable to use as my context..
.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: 10px;
}
.filling {
background-color: #4FB69F;
width: 83.33333333%; /*500px*/
margin: 1.6666666666%;
padding: 10px;
am I suppose to be using the .icing (700px) as my context or the .cake width of (600px) I tried both and still didnt get it correct.

ozlem bilis
1,579 Pointsi figured but i don't get it why padding and margin calculation is different than each other.when the video did not mention anything about padding you would guess padding is the same but it's not. which one is right? code challenge might be giving error sometimes.so are the margin and padding calculation different than each other??
.cake { background-color: #f8748f; width: 85.714285714%; /600px/ margin: 1.428571429%; /* (10/700) 100 = 1.42% */ padding: 10px; / (10/600) *100 = 1.66% */ }

Peggy Griffin
3,308 PointsIt would be helpful if additional notes about creating padding could be added somewhere in the lesson. When searching the site for 'scalable padding in css', the video 'Converting Pixels to Percentages' was the closest I could come to addressing how to handle padding. In the video, the instructor Allison changes the width of the website's container div to 90% while stating "There is no science or formula to this number. It just makes sure that we have a little bit of buffer or padding between the browser window and the content of our website." The only other mention of padding I could find in the lesson was from the 'Scalable Images' video where the instructor Allison says "Now that the text throughout our website is in EMs and our grid, margins, and paddings are in percentages,..". There doesn't seem to be any instruction on padding, other than to say 'there's no science or formula' to changing the width of the website's container div to create a padding. Could you perhaps add or alter a video to cover the topic since it's a challenge for advancing? Thanks.

Ram Narasimman (r4mbo)
Courses Plus Student 1,526 PointsGuys, why is it taking 9 months to add a section about converting padding into percentages? Its still broken and there is no mention about how to calculate padding???

Adam Field
1,183 PointsSeriously...how come the code challenge is for padding and the video was about scalable images. It makes absolutely no sense.

tugba birkel
3,593 PointsTrue !

Michael Fleischer
6,551 PointsThe padding percentage is directly related to the element the padding is located within. For example: .cake's padding is directly related to the width of .cake. Think of padding existing between the content and the walls of the container where as margins exist between the container itself and the "larger container. For example when dealing with margins, .cake was influenced by .icing because it was contained within the width of .icing. The padding however has no relation to .icing because padding stays within the dimensions of .cake.
I hope this makes sense and for that part is a correct explanation...it is after all the reason I used to solve this challenge.

mansoor ali
5,662 Pointsthe correcct answer is
10/500=2%

Andrei David
2,761 PointsThanks James Barnett, your solution has worked.

Michael Hamel
1,995 PointsI also found this to be confusing. Once James mentioned the explanation was in the HTML comments it made sense, but I have to imagine most people over looked that as I did. As it is not consistent with any of the previous quizzes, and most people assume its just "cutting and pasting" the code from the previous quiz question on the ones that build as it has also done previously. In assuming this I just shoot to the portion of the code thats relevant, not reread through the entire code each time.

branco design
5,120 Points.cake { background-color: #f8748f; width: 85.714285714%; /600px/ margin: 1.428571429%; padding: 1.6666666666666667%;

branco design
5,120 Points.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.6666666666666667%; } .filling { background-color: #4FB69F; width: 83.33333333%; /500px/ margin: 1.6666666666%; padding: 2%;
James Barnett
39,199 PointsJames Barnett
39,199 PointsThere are no special rules for padding, all you need to know is at the top of the code challenge.
If you are still having trouble create your own thread and post your code and calculations there.
Alex Colleoni
Courses Plus Student 2,415 PointsAlex Colleoni
Courses Plus Student 2,415 PointsI second Richard Rakins comment. There is a lot of inconsistencies. The tutorials are great but confusing. I am re-doing the smells like bakin website to make it fluid but upon checking the code within each video tutorials the calculations are rounded to the nearest ten. So for example, I have changed the margin of my ul.nav to 18.18 (120px / 660px = 0.1818 * 100 = 18.18)... but in the code provided by you guys, its 20% and not 18.18... So do we round number up to the nearest 10?
Jakob Herrmann
4,962 PointsJakob Herrmann
4,962 PointsThank you James Barnett. Your comment cleared it all up for me.
Joe Moors
3,334 PointsJoe Moors
3,334 PointsI also had trouble with this just now. Thanks for your input James B. I'm finding the vids are great if you are following along in a text editor (I haven't even had to look at the code that was provided, everything except for the grid.css was built from scratch following the tut's and it works great). I was confused about the padding px-% conversion as well. The only thing I can say is that another 60-90 second vid covering padding conversion would be great. I had to come here to find out it was supposed to be referenced in context to the element itself instead of the parent container.
Kamaal Khanum Williams
1,666 PointsKamaal Khanum Williams
1,666 Pointsim still having problems with this no matter the percentage I put into the challenge it stll says its wrong , does any one know the exact answer. Its quite frustrating that tree house challenges do this. Heres the code I have :
Convert the padding on .cake from pixels to percentages.???????????????????
Steven Brown
3,542 PointsSteven Brown
3,542 PointsI agree, it's inconsistent in this section. .icing is setting it's padding based on 10/700. .filling is converting it's padding based on 10/600. But .cake is converting based on 10/600? One would assume it should be .icing 10/700, .cake 10/600, and .filling 10/500. Instead it's using .icing 10/700, .cake 10/600, and .filling 10/600.