【问题标题】:Are there spacing mixins in Bootstrap 4?Bootstrap 4中是否有间距混合?
【发布时间】:2019-05-22 17:14:03
【问题描述】:

Bootstrap 4 提供了一堆间距类,它们都使用 $spacer SASS 变量。

https://getbootstrap.com/docs/4.1/utilities/spacing/

是否有任何 mixin 以便在不能(或不想)修改 html 并添加相关类的情况下将这些间距应用于元素?因此,对于没有引导类的元素,可能会有间距取决于 $spacer 值,

例如

.myClass {
    @include mt-1; //behaves like adding the mt-1 class to the element itself
}

【问题讨论】:

    标签: bootstrap-4 mixins spacing


    【解决方案1】:

    我不确定你为什么需要一个 mixin。为什么不简单地在自定义类上使用 $spacer 变量?

    .myClass {
        margin-top: $spacer*.25;
    }
    

    https://www.codeply.com/go/lfGsenoKpF

    【讨论】:

    • 谢谢,那肯定能解决问题。但我想知道在某种意义上是否有更多“说话”的东西,与“是的,$spacer*.25 在浏览器中看起来不错,所以它清楚地传达了“这应该表现得像它有这个类”我们拿走了它”。
    猜你喜欢
    • 2021-09-17
    • 2020-10-06
    • 2021-03-19
    • 2017-02-23
    • 2017-10-16
    • 1970-01-01
    • 2019-06-24
    • 1970-01-01
    • 2019-01-08
    相关资源
    最近更新 更多