如何使用SASS为不同的网格列和断点自定义Bootstrap 4?

地狱

同伴们,

我试图在大型容器上获得12列和24个装订线的大小,而在一个容器视图中处于中等和较低位置时要获得6列和18装订线的大小,而在另一个容器视图中,同时调整大小时,在大型容器上将有15列和12个装订线的大小因此,在较低的意见?

这是我可以在前者上实现的(12列24条装订线,6列18条装订线):

background-grid {

@include make-row();

@include make-col-ready;



@each $breakpoint in map-keys($grid-breakpoints) {

    @include media-breakpoint-up($breakpoint) {

        //@include make-col(map-get($dani-number-col, $breakpoint ));

        .row.no-gutters {

            margin-right: map-get($dani-row-no-gutters, $breakpoint );

            margin-left: map-get($dani-row-no-gutters, $breakpoint );

        }         

        .row > .col,

        .row > [class*="col-"] {

            margin-right: map-get($dani-gutters, $breakpoint );

            margin-left: map-get($dani-gutters , $breakpoint );

        }

    }

}

}

当我尝试做另一个容器类来代表另一个视图(15列,6个装订线)时,我无法理解。主要是因为我对CSS和SASS的理解可能很少,因此尝试使用Google搜索,但似乎没有适当的教程吗?

.foreground-container {

width: 1428px;

@include make-foreground-container();



@each $breakpoint in map-keys($grid-breakpoints) {

    @include media-breakpoint-up($breakpoint) {

        //@include make-col(map-get($dani-number-col, $breakpoint ));

        // @include make-col(15);

        .foreground-row {

            margin-right: map-get($dani-row-no-gutters, $breakpoint );

            margin-left: map-get($dani-row-no-gutters, $breakpoint );

        }         

        .foreground-row > .foreground-col,

        .foreground-row > [class*="foreground-col"] {

            margin-right: map-get($dani-row-no-gutters, $breakpoint );

            margin-left: map-get($dani-row-no-gutters, $breakpoint );

        }

    }

}

}

.foreground-row {

    @include make-foreground-row();

    // @include make-col(12);

}



.foreground-col {

    @include make-col-ready();

    @include make-col(15);

}

对于HTML,css

<div class="background-container">
  <div class="container">
    <div class="row">
      <div class="col">col1</div>
      <div class="col">col2</div>
      <div class="col">col3</div>
    </div>
  </div>
</div>

<div class="foreground-container">
  <div class="container">
    <div class="row">
      <div class="col">col1</div>
      <div class="col">col2</div>
      <div class="col">col3</div>
    </div>
  </div>
</div>

这有可能吗?如果是这样,如何以及是否不是实现我想要实现的目标的一种好方法?

谢谢。

齐姆

您可以进行自定义混合,以重新生成自定义容器内的相应断点列...

@mixin make-grid-columns-custom($columns: $grid-columns, $gutter: $grid-gutter-width, $breakpoints: $grid-breakpoints) {

  @each $breakpoint in map-keys($breakpoints) {
    $infix: breakpoint-infix($breakpoint, $breakpoints);

    // only override lg and up
    @include media-breakpoint-up('lg', $breakpoints) {
      @for $i from 1 through $columns {
        .col#{$infix}-#{$i} {
          padding-right: ($gutter / 2);
          padding-left: ($gutter / 2);
          @include make-col($i, $columns);
        }
      }

    }
  }
}

@import "bootstrap";

$foreground-container-max-widths: (
  sm: 600px,
  md: 800px,
  lg: 1000px,
  xl: 1428px
);

/* make the container for the custom grid */
.foreground-container > .container {
    @include make-container();
    @include make-container-max-widths($foreground-container-max-widths, $grid-breakpoints);
}

.foreground-container {
    /*  custom col for all breakpoints */
    @include make-grid-columns(6, 3px, $grid-breakpoints);

    /* override lg and up using custom mixin */
    @include make-grid-columns-custom(15, 6px, $grid-breakpoints);
}

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


相关:仅为页面的某个部分(div)定义不同数量的Bootstrap 4列?

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为 Bootstrap 4 创建自定义网格编号 (24)

Bootstrap 4的自定义和响应式网格宽度

如何在Bootstrap 4和Sass中设置自定义按钮的文本颜色?

如何使用angular-cli和ng-bootstrap自定义Bootstrap 4 SCSS变量?

如何使用angular-cli自定义bootstrap 4

如何使用Bootstrap 4自定义输入文件

Bootstrap 4 网格布局自定义

在自定义类Bootstap 4中的Sass中使用margin和padding变量

是否可以仅通过编辑CSS文件来在Bootstrap 4中设置自定义断点?

如何使用Bootstrap 4 Flexbox网格突破12列网格?

我如何更改或自定义警报颜色bootstrap 4和Ruby on Rails 5

使用自定义颜色和间距对中和样式化的Bootstrap 4导航栏

使用CSS和Bootstrap 4的具有平滑边缘的自定义边框

为使用Rails 4,nginx和passenger的用户设置自定义域

Bootstrap 4:一旦到达网格系统的断点,如何隐藏列?

使用bootstrap4输入空白的自定义文件

如何使用reactstrap依赖项在reactjs应用程序中自定义bootstrap 4?

如何使用自定义svg图像更改bootstrap 4导航栏折叠图标

如何使用自定义布局格式化 NavBar Bootstrap 4 布局

自定义Bootstrap 4 CSS

使用IdentityServer4和自定义配置DBContext

在 Angular CLI 应用程序的组件级样式中看不到自定义 Bootstrap 4 断点

如何在ANTLR 4中使用自定义标记和上下文

Express 4和自定义模块

NServiceBus 4和自定义SagaPersister

如何在swift 4中将html字符串设置为标签时使用常规和粗体字体设置自定义字体?

如何使用SLF4J和Log4j2记录致命(或任何自定义日志级别)

调整内容以适应不同的断点Bootstrap 4

如何在Angular 5自定义验证中使用Bootstrap 4验证伪类(:valid,:invalid)?