路径引入
1 | // Variables |
属性代替
1 | @property: color; |
延伸选择器
初步用法
1 | nav ul { |
对比混入
示例 - 使用mixin:1
2
3
4
5
6
7
8
9
10.my-inline-block() {
display: inline-block;
font-size: 0;
}
.thing1 {
.my-inline-block;
}
.thing2 {
.my-inline-block;
}
输出1
2
3
4
5
6
7
8.thing1 {
display: inline-block;
font-size: 0;
}
.thing2 {
display: inline-block;
font-size: 0;
}
1 | .my-inline-block { |
输出1
2
3
4
5
6.my-inline-block,
.thing1,
.thing2 {
display: inline-block;
font-size: 0;
}
Mixins中的选择器
1 | .my-hover-mixin() { |
循环
属性循环
1 |
|
输出:1
2
3
4
5
6
7div {
width: 10px;
width: 20px;
width: 30px;
width: 40px;
width: 50px;
}
类名循环
1 | .generate-columns(4); |
输出:1
2
3
4
5
6
7
8
9
10
11
12.column-1 {
width: 25%;
}
.column-2 {
width: 50%;
}
.column-3 {
width: 75%;
}
.column-4 {
width: 100%;
}
合并
1 | .mixin() { |
输出1
2
3.myclass {
box-shadow: inset 0 0 10px #555, 0 0 20px black;
}
父选择器
属性
1 | a { |
结果是:1
2
3
4
5
6
7a {
color: blue;
}
a:hover {
color: green;
}
类名
1 | .button { |
输出:1
2
3
4
5
6
7
8
9.button-ok {
background-image: url("ok.png");
}
.button-cancel {
background-image: url("cancel.png");
}
.button-custom {
background-image: url("custom.png");
}