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.

CSS How to Make a Website Responsive Web Design and Testing Build a Three Column Layout

Why 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
Hugo Paz
15,620 Points

Hi 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.

thank you, Hugo. I appreciate that.