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.

HTML Build a Responsive Website Creating a Fluid Foundation Scalable Images

Justinas Vaiciulis
Justinas Vaiciulis
6,944 Points

Wrong calculations for .cake padding

Hey,

so I'm trying to convert from pixels to percentage for a .cake element. I thought it's supposed to be current pixels (current padding is 10px) divided by the width of the parent element (which is .icing and it's width is 700px). So I divide 10 by 700 and then move the decimal to get 1.428571429%. However, the answer does not seem to be correct.

What am I missing here?

2 Answers

You have to divide the width of the .cake class.

10 / 600

Justinas Vaiciulis
Justinas Vaiciulis
6,944 Points

Thanks Tim! At first I couldn't understand, but then it occurred to me that we have to use the next element for calculating the margin, because margin is a distance to another object, while we need to use inside measures for calculating the padding, because padding happens in the inside of the element :)