制作一个这样的scss文件结构,
- vendors
- bootstrap
- stylesheets /*[Bootstrap 4 official sass files]*/
- _bootstrap.scss
- scss
- themes
- _theme-1.scss
- _theme-2.scss
- _variables.scss
- styles.scss
- portal-1.scss
- portal-2.scss
_variables.scss
@import "../vendors/bootstrap/stylesheets/bootstrap/variables";
@import "../vendors/bootstrap/stylesheets/bootstrap/mixins";
/* override bootstrap default variables ... */
/* custom variables with !default ... */
styles.scss
@import "variables";
@import "../vendors/bootstrap/stylesheets/bootstrap";
/* custom styles ... */
主题/_theme-1.scss
@import "../variables";
/* change value bootstrap and custom default variables ... */
$brand-primary: #428bca
$brand-success: #5cb85c;
$brand-info: #5bc0de;
$brand-warning: #f0ad4e;
$brand-danger: #d9534f;
$body-bg: #eff;
主题/_theme-2.scss
@import "../variables";
/* change value bootstrap and custom default variables ... */
$brand-primary: #C04848;
portal-1.scss
@import "themes/_theme-1";
/* change style with new variable bootstrap default components ... */
.portal-1 {
@import "../vendors/bootstrap/stylesheets/bootstrap/buttons";
@import "../vendors/bootstrap/stylesheets/bootstrap/alerts";
/* custom style overrides ... */
}
portal-2.scss
@import "themes/_theme-2";
/* change style with new variable bootstrap default components ... */
.portal-2 {
@import "../vendors/bootstrap/stylesheets/bootstrap/buttons";
@import "../vendors/bootstrap/stylesheets/bootstrap/alerts";
/* custom styles from style.scss overrides ... */
}
sass编译后我们会得到3个文件styles.css、portal-1.css和portal-2.css。
默认使用 style.css,其他包含在 head 标签中进行主题化。
<html>
<head>
<link href="styles.css" rel="stylesheet" />
<link href="portal-1.css" rel="stylesheet" />
</head>
<body>
<button class="btn btn-primary">BUTTON</button>
<div class="portal-1">
<button class="btn btn-primary">BUTTON</button>
</div>
</body>
</html>