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

HTML Build a Responsive Website Creating a Fluid Foundation Creating Flexible Margins

Converting pixels to percentages

I am having a problem with one of the objectives in this lesson: The objective is:

Using .icing as your context, convert the margins on .cake from pixels to percentages.

The icing is 800px. The margin on the cake is 10px. 10 divided by 800 is 0.0125. After moving the decimal point two places to the right, I gave 1% as my answer but that was incorrect. What am I doing wrong here?

3 Answers

I tried again just now and it worked.

.cake {
        background-color: #f8748f;
        width: 80%; /*640px*/
        margin: 1.25%;
        padding: 10px;
      }

Perhaps compare this with yours.

I don't know what I did the first time, but this time it worked. Thanks, again.

Hi Patsy,

You don't want to round off. It should be 1.25%

Thanks, but it didn't like 1.25%, either.