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

CSS How to Make a Website Styling Web Pages and Navigation Style the Portfolio

Ulises Calvo
Ulises Calvo
2,233 Points

Why margin: 2.5% only affects left and right? isn't it supposed to affect top, bottom, left and right?

When Nick sets the maging value for the gallery li element, he only specifies one value: 2.5%. Why is this only affecting left and right?. Isn't this 'one only value' property supposed to affect top, bottom, left and right altogether?

Darren Hill
Darren Hill
Courses Plus Student 9,340 Points

You're right that the one value affects all but perhaps somewhere else in the code there is a margin-top and margin-bottom set?

3 Answers

Ulises, it depends of the structure of your layout. In some cases the margin doesn't affects the element because it is kind of "stuck" where it stands. Show here the code so we can help you. You're right, the command affects all sides of the element. We need to see what else is causing the problem.

Ulises Calvo
Ulises Calvo
2,233 Points

Thank you Rafael, I actually got confused because Nick was referring specifically to how the left and right 2.5% added was making up for the 100% width of the parent element. It is clear to me now, thank you so much for your answer!!!

Darren Hill
PLUS
Darren Hill
Courses Plus Student 9,340 Points

ok. So the "gallery li" is in some sort of wrapper which is being styled with margin: 0 auto; i guess which means that the "gallery li" is inheriting the margin top/bottom from it's parent style. If that makes sense :)

Be welcome friend! Keep coding, and soon these problems will be easily solved by you.