question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Grid] Spacing with negative margins results in sometimes imprecise layouts

See original GitHub issue

I am using Grid to align-right buttons in a Card. Everything used to look super, but in recent incarnations of material-ui-next, the use of negative margins is resulting in non-ideal presentation with the right negative margin:

screenshot-localhost-3000-2018 02 09-08-10-24

The code for this is:

<CardActions>
  <Grid container justify="flex-end">
    <Grid item>
      (buttons)
    </Grid>
  </Grid>
</CardActions>

Is there a preferred implementation for what I’m trying to achieve here?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
rosskevincommented, Feb 23, 2018

@putzisan you can always make your own Grid with your own default props and simply search/replace imports. This is a simple 5 minutes or less workaround for you.

Now is the time for breaking changes, not post-1.0.

6reactions
oliviertassinaricommented, Feb 9, 2018

@bluepeter It’s hard to help without a live example of such issue. From your code, you would say that the best option is to use spacing={0}.

- <Grid container justify="flex-end">
+ <Grid container justify="flex-end" spacing={0}>
    <Grid item>

I start to think that it should be the default behavior. The negative margin can really cause trouble. It might not worth having spacing={8} by default. cc @mui-org/core-contributors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Grid] Spacing with negative margins results in sometimes ...
I am using Grid to align-right buttons in a Card. ... [Grid] Spacing with negative margins results in sometimes imprecise layouts #10223.
Read more >
The Definitive Guide to Using Negative Margins
If the negative margin is equal to the actual width, then it overlaps it entirely. This is because margins, padding, borders, and width...
Read more >
WPF: Grid with column/row margin/padding? - Stack Overflow
The idea is simple, use a grid on the outside to pull the margins of elements out of their bounds by half the...
Read more >
Flexbox gutters and negative margins, mostly solved - Rawkblog
The issue is the 1rem of margin all around, which creates uneven design and prevents flush sides.
Read more >
Negative Stress Margins – Are They Real?
The structural areas where negative margins are frequently encountered are often near stress concentrations, point loads and load discontinuities, near ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found