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.

The `Row` component will overflow when setting gutter

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.4.1

Environment

os: mac os 12, browser: chrome 65

Reproduction link

https://zhuchuji.github.io/antd-issues/

Steps to reproduce

  1. Layout with Row and Col
  2. Set gutter to the Row

What is expected?

The Row should not overflow

What is actually happening?

The Row overflows and produces the scrollbar


Antd sets margin-left and margin-right to a negative value on Row to compensate the padding-left of the first Col child and padding-right of the last Col child, which will make the Row box larger than its parent as it’s set to box-sizing: border-box. Users have to provide a container with padding to ensure the Row will not overflow, which is a big problem in layout especially in responsive web, because they have to set variables for gutters and calculate it for the padding of the container. It’s totally inconvenient. If the grid system removes the first column’s padding-left and the last column’s padding-right, the Row does not need a negative margin any more. Perhaps, it could be fixed by adding a container in Row, so that you don’t have to detect which column is the first child and which is the last.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:24
  • Comments:36 (4 by maintainers)

github_iconTop GitHub Comments

50reactions
afc163commented, Aug 30, 2018

You can add a wrapper with overflow: hidden as workaround: https://codesandbox.io/s/oonl1ylnvy

There is no solution about this problem now.

32reactions
orlandocommented, Jul 31, 2019

Here’s what I think is a better workaround with CSS:

.ant-row {
  margin-right: 0 !important;
  margin-left: 0 !important;
}

.ant-col:first-child {
    padding-left: 0 !important;
}

.ant-col:last-child {
  padding-right: 0 !important;
}

This removes the margins from the Row component and the padding of the first and last Col

Read more comments on GitHub >

github_iconTop Results From Across the Web

The `Row` component will overflow when setting gutter #10144
This fails when using responsive breakpoints that cause columns to wrap. The rows that get created when hitting the various breakpoints (i.e. xs,...
Read more >
Grid and Ant Design - reactjs - Stack Overflow
I don't use Ant Design but I though <Row /> component is wrapper and it should wrap all your <Col />. So, if...
Read more >
Grid - Ant Design
If the sum of col spans in a row are more than 24, then the overflowing col ... You can use the gutter...
Read more >
Gutters · Bootstrap v5.0
Gutters are the gaps between column content, created by horizontal padding . We set padding-right and padding-left on each column, and use negative...
Read more >
scrollbar-gutter - CSS: Cascading Style Sheets - MDN Web Docs
stable. When using classic scrollbars, the gutter will be present if overflow is auto , scroll , or hidden even if the box...
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