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.
.cake margin using .icing as context
.icing width = 100% / 800 px
.cake margin = 10px
I would think the formula would be 10 / 800 = .01, making the margin 1%.
Where am I going wrong?
So the width of .icing is 800(px) and the margin on .cake is 10(px). Using target/context we can get the answer
10/800 * 100 = 1.25%
Oh, my calculator was rounded to 2 decimal places, so I didn't realize it was 1.25 instead of just 1. Thanks!
Valery Kukatov6,996 Points
I just checked it out... what you have to do is use the formula... Target/Context. Your target is .icing In there it states in the comment that it's 800px Your context is .cake In there it states in the comment that it's 640px
So 800/640 = 1.25% That is your margin in percentages.
I hope that makes sense. :)