css - 如何在 Twitter bootstrap sass 中创建列(alpha 4)

标签 css twitter-bootstrap sass mixins bootstrap-4

我正在尝试使用 SASS 提供的 make-col() mixin。 http://v4-alpha.getbootstrap.com/layout/grid/ .我想要做的是创建两列。使用已编译的类,我可以做




我得到两个 div,它们以任何大于 sm 的大小彼此相邻 float .

在 Bootstrap Sass 中(我在 React 中使用它),当我这样做时:

.row {
    @include make-row()
}
.left {
    @include make-col(3)
}
.right {
    @include make-col(9);
}

它确实使两者相邻 float ,但是当我将屏幕缩小时,两者不会被遮挡。它们保持 float 。使用 mixins 时,如何让 Bootstrap 镜像上述示例。

顺便说一句,从文档中:@mixin make-col($size, $columns: $grid-columns, $gutter: $grid-gutter-width) - 究竟是什么size ?是列数吗?我很困惑,因为还有一个 $columns多变的。

最佳答案

更新

Bootstrap 4.1< ,有可用于完成网格系统特定任务的 mixin。这些是与列相关的功能:

@include make-col-ready()
@include make-col($size, $columns: $grid-columns)
@include make-col-offset($size, $columns: $grid-columns)

示例用法

HTML
<div class="example-container">
  <div class="example-row">
    <div class="example-content-main">Main content</div>
    <div class="example-content-secondary">Secondary content</div>
  </div>
</div>

萨斯
.example-container {
    width: 800px;
    @include make-container();
}
.example-row {
    @include make-row();
}
.example-content-main {
    @include make-col-ready();

    @include media-breakpoint-up(sm) {
        @include make-col(6);
    }
    @include media-breakpoint-up(lg) {
        @include make-col(8);
    }
}
.example-content-secondary {
    @include make-col-ready();

    @include media-breakpoint-up(sm) {
        @include make-col(6);
    }
    @include media-breakpoint-up(lg) {
        @include make-col(4);
    }
}

资料来源:
  • Official Documentation
  • Bootstrap Mixins Cheatsheet
  • 关于css - 如何在 Twitter bootstrap sass 中创建列(alpha 4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39607788/

    相关文章:

    html - 如何在网格列内定位 Bootstrap 弹出窗口?

    sass - 如何在 PhpStorm 中正确设置 scss 文件观察器?

    angular - Ionic 3 网格无法将行项目垂直居中

    css - 如何在 SASS 中将一个字符串拆分为两个数字列表?

    javascript - 如何管理Bootstrap 4网格?

    css - 哪些 Internet Explorer 设置会导致 IE7/IE8 不加载 css?

    javascript - html javascript 折叠 Accordion

    html - 如何在浏览器放大/缩小期间保持 SVG 大小相同

    css - Twitter Bootstrap Navbar 下拉样式

    twitter-bootstrap - 如何将背景图像放在 col-md 中