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 trialhoppy bouasavanh
Courses Plus Student 1,791 PointsWhy the margin of ".gallery li" is 2.5% instead of 5%? PLEASE,
According to my understanding,
Gallery is divided to 45% out of 100%. THere are 2 colomns which mean 45% * 2 = 90%
remaining 100% - 90% = " 10% " (Total margin)
10% of total margin is divided by 2 = " 5% " for each margin.
My wonder is why we choose 2.5% as margin for ".gallery li"?
1 Answer
Hugo Paz
15,622 PointsHi hoppy,
If each column is 45% wide and you have 2, you have 90% of the full width.
when you set the margin of an element like this margin: 2.5% what happens is a a margin around the element of 2.5%
|
[ -- element --] |
so the element has: margin-left: 2.5%, margin-right: 2.5% margin-top:2.5%, margin-bottom:2.5%
If you add margin-left and margin-right you get the 5% you are looking for.
hoppy bouasavanh
Courses Plus Student 1,791 Pointshoppy bouasavanh
Courses Plus Student 1,791 Pointsthank you, Hugo. I appreciate that.