什么是&;用css做什么
我正在查看一些遗留代码,在css文件中发现如下内容:什么是&;用css做什么,css,Css,我正在查看一些遗留代码,在css文件中发现如下内容: .user_modal { width: auto; height" auto; &.modal, &.fade.in { margin-top:0; margin-left:0; top:83px; } } &here的用途是什么?它看起来像Sass或更少。它是user\u modal,其中的其他类不是它的子类。&是对它上面的元素/类的引用。您可能对选择器很有经验。sass
.user_modal {
width: auto;
height" auto;
&.modal,
&.fade.in
{
margin-top:0;
margin-left:0;
top:83px;
}
}
&here的用途是什么?它看起来像Sass或更少。它是
user\u modal
,其中的其他类不是它的子类。&
是对它上面的元素/类的引用。您可能对选择器很有经验。sass中的&
用于引用父选择器。因此,在您的情况下,&
将引用父选择器,它是.user\u modal
因此,和.modal
将转换为CSS并成为.user\u modal.modal
因此,它将匹配:
<div class='user_modal modal'></div>
最后,在转换后,它就变成了普通的CSS:
.user_modal.modal , .user_modal.fade.in {
margin-top:0;
margin-left:0;
top:83px;
}
对我来说,这看起来像一个预处理器样式表,而不是普通的CSS。您确定正在查看的文件的扩展名为.css吗?它可能是SASS中的父选择器引用。无论如何,
height”auto;
中存在语法错误,因此如果使用生成SASS错误编译此代码,则可能会重复
.user_modal.modal , .user_modal.fade.in {
margin-top:0;
margin-left:0;
top:83px;
}