Removing padding gutter from grid columns in Boots

2020-03-01 01:49发布

How do you create a gutterless grid in bootstrap 4?

Is there an official API for removing the gutter or is it manual?

5条回答
聊天终结者
2楼-- · 2020-03-01 02:29

You should use built-in bootstrap4 spacing classes for customizing the spacing of elements, that's more convenient method .

查看更多
Viruses.
3楼-- · 2020-03-01 02:36

Need an edge-to-edge design? Drop the parent .container or .container-fluid.

Still if you need to remove padding from .row and immediate child columns you have to add the class .no-gutters with the code from @Brian above to your own CSS file, actually it's Not 'right out of the box', check here for official details on the final Bootstrap 4 release: https://getbootstrap.com/docs/4.0/layout/grid/#no-gutters

查看更多
forever°为你锁心
4楼-- · 2020-03-01 02:40

Bootstrap4: Comes with .no-gutters out of the box. source: https://github.com/twbs/bootstrap/pull/21211/files

Bootstrap3:

Requires custom CSS.

Stylesheet:

.row.no-gutters {
  margin-right: 0;
  margin-left: 0;

  & > [class^="col-"],
  & > [class*=" col-"] {
    padding-right: 0;
    padding-left: 0;
  }
}

Then to use:

<div class="row no-gutters">
  <div class="col-xs-4">...</div>
  <div class="col-xs-4">...</div>
  <div class="col-xs-4">...</div>
</div>

It will:

  • Remove margin from the row
  • Remove padding from all columns directly beneath the row
查看更多
疯言疯语
5楼-- · 2020-03-01 02:48

You can use this css code to get gutterless grid in bootstrap.

.no-gutter.row,
.no-gutter.container,
.no-gutter.container-fluid{
  margin-left: 0;
  margin-right: 0;
}

.no-gutter>[class^="col-"]{
  padding-left: 0;
  padding-right: 0;
}
查看更多
太酷不给撩
6楼-- · 2020-03-01 02:52

You can use the mixin make-col-ready and set the gutter width to zero:

@include make-col-ready(0);

查看更多
登录 后发表回答