web前端全系列 教程
1839个小节阅读:2243.3k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
混合允许您将一个类的属性用于另一个类,并且包含类名作为其属性
xxxxxxxxxx
.p1 {
color: red;
}
.p2 {
background: #64d9c0;
.p1();
}
.p3 {
background: #DAA520;
.p1;
}
如果你想创建一个混合,但是你不希望这个混合出现在你的CSS中,在混合定义后面加圆括号
xxxxxxxxxx
.my-mixin {
color: black;
}
.my-other-mixin() {
background: white;
}
.class {
.my-mixin();
.my-other-mixin();
}
!important
在混合调用后使用!important关键字将它继承的所有属性标记为!important
xxxxxxxxxx
.foo (@bg: #f5f5f5; @color: #900) {
background: @bg;
color: @color;
}
.unimportant {
.foo();
}
.important {
.foo() !important;
}
混合也可以接受参数,这些参数是混合时传递给选择器块的变量
xxxxxxxxxx
.border-radius(@radius,@color:red) {
border-radius: @radius;
color: @color
}
#header {
.border-radius(4px,blue);
}
.button {
.border-radius(6px);
}
实时效果反馈
1. 下列代码输出的CSS结果是:
xxxxxxxxxx
.border-radius(@radius,@color:red) {
border-radius: @radius;
color: @color
}
.button {
.border-radius(6px);
}
A
xxxxxxxxxx
.button {
border-radius: 6px;
}
B
xxxxxxxxxx
.button {
border-radius: 6px;
color: "";
}
C 编译报错
D
xxxxxxxxxx
.button {
border-radius: 6px;
color: red;
}
答案
1=>D