假设你有这个SASS定义(不真实的例子):
.class {
margin: 1px;
background: black;
color: white;
&:hover {
color: red;
}
}
a.class {
margin: 1px;
background: black;
color: yellow;
&:hover {
color: blue;
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我们可以将a同一类的规范作为嵌套选择器吗?像这样的东西(伪代码):
.class {
margin: 1px;
background: black;
color: white;
&:hover {
color: red;
}
// Some selector to show that the current class
// should be applied to this element (?)
a.& {
color: yellow;
&:hover {
color: blue;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个解决方案.它有点棘手,但它的工作正常.
.class {
color: yellow;
&:hover {
color: blue;
}
&[href] {
color: white;
&:hover {
color: red;
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
82 次 |
| 最近记录: |