Bootstrap 更少 - 覆盖整个 class

Bootstrap less - override entire class

我正在使用 Bootstrap less 文件。我宁愿不直接修改它们,因为这似乎是不好的做法。 我正在编辑的唯一文件是 bootstrap.less,因为我需要添加覆盖 类。

type.less我要修改这个:

.page-header {
  padding-bottom: ((@line-height-computed / 2) - 1);
  margin: (@line-height-computed * 2) 0 @line-height-computed;
  border-bottom: 1px solid @page-header-border-color;
}

所以我创建了一个新的 _type.less 包含这个:

.page-header {
  background: blue;
}

这在 bootstrap.less 主文件中被引用:

@import "type.less";
@import "../bootstrap-custom/_type.less";

我遇到的问题是编译器输出 类 到 bootstrap.css - 我想覆盖原来的,这样它只使用我的实现。

这可能吗?

不要在主 bootstrap.less 中调用 less,在 less 文件顶部调用 bootstrap.less。

此外,您还需要覆盖 .page-header 中的每个定义

.page-header {
     padding-bottom: 0;
     margin: 0;
     border-bottom: none;
     background: blue;
   }