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 trialUlises Calvo
2,233 PointsWhy 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?
3 Answers
RAFAEL COSTA
6,243 PointsUlises, 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
2,233 PointsThank 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
Courses Plus Student 9,340 Pointsok. 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 :)
RAFAEL COSTA
6,243 PointsBe welcome friend! Keep coding, and soon these problems will be easily solved by you.
Darren Hill
Courses Plus Student 9,340 PointsDarren Hill
Courses Plus Student 9,340 PointsYou're right that the one value affects all but perhaps somewhere else in the code there is a margin-top and margin-bottom set?