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 trialRasmus Boll
4,371 PointsAlready know the correct answer, but can someone explain it
Hi there,
The quiz question is: "Say we have two floated list items with a width of 45% each. Which of the following declarations, if applied to the list items, will perfectly fill the remainder of the parent element’s width?"
The answers can be: "Margin: 10%;" "Margin: 100%;" "Margin: 2.5%;" "Margin: 0%;"
I already know the correct answer is 2,5. But that is only because I remembered it from watching the video. What I would like to know, is if there is someone who can explain it to me, so I can understand why this is the correct answer. I have watch the video over and over agin, but somehow I still don´t understand it, maybe it is because english isn´t my mother language, is there anyone how can explain it to me like I am a six year old kid??
1 Answer
Nikki Bollman
7,281 PointsHere's how I understand it:
We want to make the total width of everything in the parent element equal to 100%. Since the floated list items take up 45% each, together they make up for 90% of the total width. To perfectly fill the remainder, the margins need to take up the remaining 10% of the width. Since there are 4 sides (2 for each list item), we divide that 10% by 4 to get 2.5%.
Moderator Edit: Moved response from the Comments section to Answers.
Rasmus Boll
4,371 PointsThank you Nikki Bollman, I think I got it now
Tomas Pavlik
26,726 PointsTomas Pavlik
26,726 PointsNikki si absolutely right - each side takes 2.5% (10% total).