1. 为什么学习函数?
随便写的css代码:
.left {
width: 30px;
height: 30px;
text-align: centyer;
line-height: 30px;
background-color: red;
}
.right {
width: 30px;
height: 30px;
text-align: centyer;
line-height: 30px;
background-color: blue;
}
提取公共部分封装成一个公共的类名common:
.common {
width: 30px;
height: 30px;
text-align: centyer;
line-height: 30px;
}
.left {
background-color: red;
}
.right {
background-color: red;
}
在CSS中我们可以提取公共的CSS代码进行公共类名的封装
在scss中我们还可以封装@function和@mixins
其实这就是JS函数的作用,他们都有一个共同的目的:
1. 减少了代码
订阅专栏 解锁全文
761

被折叠的 条评论
为什么被折叠?



