Balance Sheet step 42

I don’t have a problem with code but still don’t understand one thing. Here’s the code, I’ll explain:

#years {
  display: flex;
  justify-content: flex-end;
  position: sticky;
  top: 0;
  background: #0a0a23;
  color: #fff;
  z-index: 999;
  margin: 0 -2px;    /* Why are we setting left and right margins to -2px? */
  padding: 0.5rem calc(1.25rem + 2px) 0.5rem 0;

So, why are we setting this margin here? Is it only so we can learn how to use “calc” or is it due to something I don’t see?

Thanks!

“While a positive margin value pushes other elements away, a negative margin will either pull the element itself in that direction or pull other elements toward it.”
Take a look at this page:

You can try it on the Codepen platform and see what is going on when you change the margin’s value.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.