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

Scrambled images

Convert the padding on .cake from pixels to percentages.

I really don't have code to give and I know you need to divide, but can you give me a hint or a little more information it would be gratefully appreciated. your the best in the World.

6 Answers

For Example:

Currently the Padding is 20px.
The Width is 400px.

To turn the Padding from Pixels to %
20 divided by 400 = 0.05
0.05 multiplied by 100 = 5%
Therefore Padding: 5%;

Hopefully this is a little clearer.

Divide the size on the cake by 16px and move the decimal two spaces over.

@Chase James In this situation it is converting to % not ems. Your solution works if converting an object from pixel to em and the base font is 16px.

Tony McCabe

I take notes of everything, Its like going too school. Thanks very much

Chase,

You said to divide on the size of the cake. Do you mean all width, margin and padding. What should I divide? Your on the right track, but a little more would be killer. I don't want the answer, but give me an example please?

Example:

p{ width: 400px; padding: 5%; /* Padding is 20px hence 20px / 400px *100 = 5% */

}

You just totally lost me Nathan. I'm trying to pick your brain, but unfortunately I'm not that intelligent sorry guy's. you new to explain a little more clear.