【问题标题】:Bootstrap 4, scss @import generates a different file than the original on getbootstrap.comBootstrap 4,scss @import 生成与 getbootstrap.com 上的原始文件不同的文件
【发布时间】:2018-01-31 06:50:14
【问题描述】:

我在我的项目中使用node-sass

您可以尝试使用两个版本(alpha6 和 beta)的简单 style.scss 文件:

@import "./node_modules/bootstrap/scss/bootstrap";

然后输入:

node-sass style.scss style.css

你会有一个不同的 .btn 类的 css:

- getbootstrap.com (https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.css) 上的原始版本

.btn {
  display: inline-block;
  font-weight: normal;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  border: 1px solid transparent;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  line-height: 1.25;
  border-radius: 0.25rem;
  transition: all 0.15s ease-in-out;
}

- 生成一个

.btn {
  display: inline-block;
  font-weight: normal;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  user-select: none;
  border: 1px solid transparent;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  line-height: 1.25;
  border-radius: 0.25rem;
  transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

看看这个:

transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;

为什么会有这种差异?

由于这个问题,按钮上的“禁用”属性不再有过渡,您可以在此处看到:https://plnkr.co/edit/LSeKKSaB2Lk2JMtoFi9K?p=preview

【问题讨论】:

    标签: css twitter-bootstrap twitter-bootstrap-3 bootstrap-modal bootstrap-4


    【解决方案1】:

    简而言之,您的构建过程(基于您的描述)仅包括 Bootstrap 在发布之前对其 .sass 文件所做的部分操作。

    Bootstrap 除了将 Sass 编译为 CSS 之外,还使用 ​​Autoprefixer 等工具来修复最常见的跨供应商 CSS 问题,例如,向某些属性添加供应商前缀(参见 .btn 中的 user-select )。您只是错过了这一步,因此您的结果文件看起来有点不同。

    来源:http://getbootstrap.com/docs/4.0/getting-started/build-tools/#tooling-setup

    【讨论】:

    • 好的,谢谢。我使用该导入是因为我需要覆盖一些变量(例如:$enable-rounded: false; -shadows: true;)。该怎么做?
    • 这与导入无关,您可能没有设置 Autoprefixer。
    • 什么意思?
    • Bootstrap 在他们的构建过程中使用 Autoprefixer,一个 postcss 插件,对编译后的 Sass 代码进行一些自动改进。您没有在构建过程中包含 Autoprefixer,因此您的最终 Bootstrap 包看起来不同。阅读我在答案中链接的网站,您就会知道出了什么问题。
    • 好的,谢谢。但是我的问题是关于在线和我的 CSS 的不同属性值。除了现在我知道的自动前缀。看看过渡道具。
    猜你喜欢
    • 2016-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-04
    • 2018-05-23
    相关资源
    最近更新 更多