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 trialFung How Lim
2,402 PointsWhy is it important to set margin-right to -4px?
Since padding-left and right are both set at 1em, why should we set margin-right at -4px?
I don't quite understand what this -4px does.. Would be perfect if you could help with this. Thanks!
Best, S.
2 Answers
Joey Bruijns
Full Stack JavaScript Techdegree Graduate 47,878 PointsHi,
I think itβs because in the video the .col class is set to inline-block. This display value creates some undesirable extra white-space between the columns, making them break the layout. The negative margin is one way to fix that problem and make sure your layout behaves like you intended.
Hereβs some extra explanation
Martin Chaffee
Front End Web Development Techdegree Student 15,278 PointsActually, it's the padding that removes the "undesirable white-space between the columns". The -4px right margin allows the columns to appear beside each other in the first place; without the negative margin, each column is too wide to sit side-by-side, and the second column is pushed below the first.
Fung How Lim
2,402 PointsFung How Lim
2,402 Pointsthanks for the additional info! :) cheers!