1. 何時使用混合器
2. 混合器中的css規則
```
@mixin no-bulletes {
list-style: none;
li {
list-style-image: none;
list-style-type: none;
margin-left: 0px;
}
}
ul.plain {
color: #444;
@include no-bulletes;
}
```
最終生成如下代碼:
```
ul.plain {
color: #444;
list-style: none;
}
ul.plain li {
list-style-image: none;
list-style-type: none;
margin-left: 0px;
}
```
3. 給混合器傳參(類似JavaScript的function)
```
@mixin link-colors($normal, $hover, $visited) {
color: $normal;
&:hover { color: $hover; }
&:visited { color: $visited; }
}
a {
@include link-colors(blue, green, yellow);
}
```
示例:封裝一個三角
```
@mixin trangle($local, $size, $deg) {
&::#{$local} {
display: block;
content: "";
width: 0;
height: 0;
position: relative;
border: $size solid #333 {
left: { color: transparent; }
right: { color: transparent; }
top: { color: transparent; }
}
transform: rotate($deg);
}
}
```
4. 默認參數值
```
@mixin link-colors($normal, $hover:$normal, $visited:$normal)
{
color: $normal;
&:hover { color: $hover; }
&:visited { color: $visited; }
}
li {
@include link-colors(red);
}
```
- 空白目錄
- 1. css選擇器
- 1.1 基礎選擇器
- 1.2 偽類
- 1.3 first-child與:first-of-type的區別
- 1.4 nth-child(:not())與nth-of-type(:not())
- 1.5 屬性選擇器
- 2. html標簽分類&css樣式繼承
- 2.1 html標簽分類
- 2.2 樣式繼承
- 2.3 font
- 3. css動畫
- 1. transition
- 2. animation
- 4. 布局位置方面
- 4.1 實現圖片左右垂直居中
- 4.2 父元素中第一個子元素margin-top無效問題
- 4.3 position定位
- 5. 關于浮動
- 5.1 浮動的呈現效果
- 5.2 清除浮動的三種方式
- 5.3 inline-block與block浮動的對比
- 6. 彈性布局
- 7. border
- 7.1 添加border不影響盒子大小的三種方式
- 7.2 利用border畫三角形
- 8. css預處理--sass
- 8.1 變量
- 8.2 嵌套
- 8.3 導入SASS文件
- 8.4 靜默注釋
- 8.5 混合器@mixin
- 8.6 繼承@extend
- 8.7.function
- ! element語法
- 9. grid 布局
- 10. filedset 使用
- css面試題
- 1.題目匯總
- 2.回流(重排)和重繪
- 3.瀏覽器渲染流程
- 4.水平垂直居中
- 5.flex布局