前端常用类名定义样式,但是遇到一些重复的样式,可以考虑使用多类型写法,实现代码公复用!举例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 100px;
height: 100px;
}
.divRed {
background-color: red;
}
.divGreen {
background-color: green;
}
.font35 {
font-size: 40px;
}
</style>
</head>
<body>
<div class="box divRed">红色</div>
<div class="box divGreen">绿色</div>
<div class="box divRed font35">红色</div>
</body>
</html>