html - 我们怎样才能最小化 bootstrap 3 中的 gutter-width?

标签 html css twitter-bootstrap twitter-bootstrap-3

我们如何在 bootstrap 3 中最小化 gutter-width?由于 Bootstrap 遵循 12 网格系统,因此当我使用 col-sm-* 放置我的内容时,它会在元素之间留出一些像素的间隙(比如 30px,即网格列两侧的 15px),但我的要求主题不需要太多列之间的空间。所以,我应该怎么做才能最小化那个空间?

最佳答案

如果您不想生成自定义的 Bootstrap 构建,这里有一种 CSS 技术将覆盖列之间的 Bootstrap 填充(装订线)。

/* remove spacing between middle columns */
.row.no-gutter [class*='col-']:not(:first-child):not(:last-child) {
  padding-right:0;
  padding-left:0;
}
/* remove right padding from first column */
.row.no-gutter [class*='col-']:first-child {
  padding-right:0;
}
/* remove left padding from last column */
.row.no-gutter [class*='col-']:last-child {
  padding-left:0;
}

演示:http://bootply.com/109530

另一种选择(将装订线减少一半 - 15px):

.row-smaller {
    margin-left: -7.5px;
    margin-right: -7.5px;
}

.row-smaller > div[class^="col"] {
    padding-left: 7.5px;
    padding-right: 7.5px;
}

演示:https://www.codeply.com/go/pb9pQzThUy

此技术也适用于 Bootstrap 4:https://www.codeply.com/go/SZcY3X4hTY

关于html - 我们怎样才能最小化 bootstrap 3 中的 gutter-width?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21450669/

相关文章:

html - HTML 网站上使用的 Wordpress 革命 slider

javascript - 移动 Chrome 上的 IFrame 播放器 API

html - 在 Internet Explorer 9 中使用 HTML5 直播 h.264

javascript - 无法加载资源 : the server responded with a status of 404 (Not Found) with nodejs

html - 100% 时 div 元素的高度与父元素的高度不匹配

jquery - Angular-cli bootstrap v3 和 jquery? Angular 2.0

html - 样式化 HTML5 输入类型编号

javascript - 如何阻止菜单中的此幻灯片滚动到网页顶部?

html - 刚刚注意到 Twitter 上的 `<i/>` 标签,这是他们编造的吗?

html - 我希望所有屏幕尺寸的 Logo 和标题居中