什么是“&”前面的一个伪元素在CSS中的意思? [英] What does an "&" before a pseudo element in CSS mean?
本文介绍了什么是“&”前面的一个伪元素在CSS中的意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在以下来自 Twitter Bootstrap 的CSS中,&符号(&)字符是什么意思?
In the following CSS taken from Twitter Bootstrap what does the ampersand (&) character mean?
.clearfix {
*zoom: 1;
&:before,
&:after {
display: table;
content: "";
}
&:after {
clear: both;
}
}
推荐答案
LESS ,而不是CSS。
此语法允许嵌套嵌套选择器修饰符。
This syntax allows you nest nest selector modifiers.
.clearfix {
&:before {
content: '';
}
}
将编译为:
.clearfix:before {
content: '';
}
使用&
,嵌套的选择器编译为 .clearfix:before
。
没有它,它们编译为 .clearfix:before
。
With the &
, the nested selectors compile to .clearfix:before
.
Without it, they compile to .clearfix :before
.
这篇关于什么是“&”前面的一个伪元素在CSS中的意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文