【问题标题】:How to apply flex behaviors in a row via sass?如何通过 sass 连续应用 flex 行为?
【发布时间】:2019-05-09 23:04:48
【问题描述】:

例如我有这个 HTML:

    <div class="header__container">
      <div class="header__info-row">
        <section class="social__col">
        </section>
        <section class="contact__col">
        </section>
      </div>
    </div>

使用 sass,我可以像这样指定行和列:

    .header__container {
      @include make-container();
    }

    .header__info-row {
      @include make-row();
    }

    .header__navigation-row {
      @include make-row();
    }

    .social__col {
      @include make-col-ready();

      @include media-breakpoint-up(xs) {
        @include make-col(6);
      }
    }

    .contact__col {
      @include make-col-ready();

      @include media-breakpoint-up(xs) {
        @include make-col(6);
      }
    }

有没有办法在 sass flex-behaviors 内部指定 d-flex、justify-content、align-content 等?

【问题讨论】:

  • 是什么阻止您使用display: flex; 和普通的 CSS 规则?

标签: twitter-bootstrap sass bootstrap-4


【解决方案1】:

在 Bootstrap 的文档中可以看到,除了 sass mixins,它们还提供了类来控制网格元素的 css 行为。例如

<div class="row justify-content-center">
<div class="row justify-content-end">
<div class="col align-self-start">

所以我很确定,如果你摆弄这些类,你会得到你想要的行为。

如果您想要自定义解决方案,请编写自己的 sass mixin 并将其包含在 Bootstrap 的 mixin 之后,以覆盖它们提供的默认值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-12
    • 2021-06-20
    • 1970-01-01
    • 2013-10-26
    相关资源
    最近更新 更多