daneden / Toast

🍞 A highly-customizable, responsive (S)CSS grid
http://daneden.github.io/Toast
MIT License
2k stars 271 forks source link

Negative margin on grid? #43

Closed henrikra closed 8 years ago

henrikra commented 8 years ago

Why on grid class there is negative margin on right? margin-right: -0.25em; It messes up the columns a bit. Is this a bug or is there a reason?

daneden commented 8 years ago

It’s there for a reason—setting the columns to display: inline-block means that they honor the whitespace in markup, putting regular word spaces between each column. The negative margin is there to counter the whitespace.

However, if you delete the whitespace in your markup (or if it’s never present—for instance, React eliminates whitespace in its rendered components), then the negative margin is problematic.

One fix is to add a modifier to the grid container to remove whitespace from the columns:

.o-grid--no-whitespace {
  .o-grid__col {
    margin-right: 0;
  }
}
henrikra commented 8 years ago

Wow thanks! I am actually using React in my project and that is why I don't have any whitespace. Thank you for fast response.