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

Charles Burke
Charles Burke
2,351 Points

Cannot figure out Margin formula

So. The instruction is: "Using .cake as your context, convert the margins on .filling from pixels to percentages."

With that in mind. My mortal mind says it would be 10px / 640px = .0156 x 100 ( moving the decimal to places) = 1.56%

Doesn't work .

What did I miss. This is incredibly frustrating. Thanks

I would move the decimal over one more like 15.66666% Try that maybe. Or round up to 2%

margin: 10px 0 0 16.666667%;

8 Answers

Charles Burke
Charles Burke
2,351 Points

Ok. Got this straightened out. Despite the fact that the instructor says, don't worry about ALL the places behind the decimal because the browser rounds it anyway, I had to carry it all the way. so 1.5625% is what I needed to put in the code. I did that and it worked. Go figure.

Thank you both again for taking the time, to respond. I appreciate it very much.

Charles Burke
Charles Burke
2,351 Points

Thank you Stef for your help. But it did not work. I have tried dividing target / context = result for every class. No go. This is a trick question I think. Because following the formula it should be 10px / 640px = .015625 moving the decimal again did not help. rounding up to two did not help.

Here is a link to the exercise....

http://teamtreehouse.com/library/build-a-responsive-website/creating-a-fluid-foundation/creating-flexible-margins

Thank you again for your time and help. I appreciate it.

Isn't that asking for 800px then and not 640? which would be 0.0125% If I'm not mistaken.

Charles Burke
Charles Burke
2,351 Points

I may have posted the wrong link. Here is the instruction copied from the page:

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

using THAT instruction it seems that I should be dividing 10 x 640.

I do not think they are asking for top/bottom AND side margins...left or right...so I don't know. I'm walking away. Maybe if I come back later....Thanks again for helping Stef! I appreciate it .

David Lane
David Lane
33,414 Points

Your calculation is 10/640 giving you 0.015625. Then all that is left is to adjust the decimal for percent (1.5625%).

Thanks Dave. Charles, if you indeed gave the wrong link then what you're attempting to do is PADDING and not MARGIN. Because that course states that clearly in the comment above the markup to use icing and if not to then use the element itself. Perhaps the course meant for you to configure the padding and not the margin? Not sure.

Charles Burke
Charles Burke
2,351 Points

Aloha David and Stef...Thanks for your help. I used the 10/640 and entered the 1.56%

It did not work. Definitely this is a margin exercise. I have used the 10/800 10/1000 10/640.

I shall open a ticket...because obviously I am missing something really stupid...or there is a bug in the program.

Thank you both for taking the time to respond. I appreciate it.

Charles Burke
Charles Burke
2,351 Points

Aloha David and Stef...Thanks for your help. I used the 10/640 and entered the 1.56%

It did not work. Definitely this is a margin exercise. I have used the 10/800 10/1000 10/640.

I shall open a ticket...because obviously I am missing something really stupid...or there is a bug in the program.

Thank you both for taking the time to respond. I appreciate it.