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
Ben Watkins
20,377 PointsHelp with challenge 1 of "Creating flexible margins" code challenge?
I've tried all sorts, nothing seems to work... "Using .icing as your context, convert the margins on .cake from pixels to percentages." CSS : "icing { background-color: #B4C34F; width: 100%; /800px/ padding: 10px; } .cake { background-color: #f8748f; width: 80%; /640px/ margin: .8%; padding: 10px; }"
Ben Watkins
20,377 PointsThanks!
2 Answers
John Paul Ashenfelter
1,118 PointsThanks for the answer Ronnie!
Ben Watkins
20,377 PointsGuys, I've just moved onto the Salable images challenge and have run into another problem.
"To calculate the correct percentage in your case, take 10 (10px) and divide by 800 (800px). So, 10/800 = 0,0125 which then gives you 1.25%."
this time we are dividing by 700, because the width of .icing is the equivalent to 700px, so, 10/700 = 0.01428571428 so surely 1.428571428% would be the answer? Apparently not...
henrikh
3,666 PointsTry figure out your self, the answer for the first result was 0,0125, but it doesn't mean that it's equal to 0,0125%, it's 1.25%, what have you tried so far? 1.42%?
Ben Watkins
20,377 PointsYep, trust me, I'm not just asking and getting my answers that way, I just generally can't get it to work... I've tried 1.42% 1.4% 1.428571428% and more, nothing seems to work, I know the answer, as when submitting any of these the padding doesn't change on the preview, I just don't know which variant of it treehouse accepts.
henrikh
3,666 PointsOk, you have to understand that there is a difference in padding and margins. When setting ?exible padding on an element, your context is the width of the element itself.
So, the correct answer would be 0,0166666666666667 (10/600) giving you 1.66% (this is stated in the STYLE description above the code in the question.
Ben Watkins
20,377 PointsOkay, thanks!
henrikh
3,666 Pointshenrikh
3,666 PointsHey Ben!
If you watch the small video, before doing the quiz, it's really simple. You can't just put a % sign there, and make it work. You would need to check the width on the icing first, then calculate it.
To calculate the correct percentage in your case, take 10 (10px) and divide by 800 (800px). So, 10/800 = 0,0125 witch then gives you 1.25%.