ban*_*aka 37
究竟.在萨斯你可以有这样的东西......
div {
background: green;
p {
background: red;
&:hover {
background: blue;
}
&:active {
background: blue;
}
}
}
Run Code Online (Sandbox Code Playgroud)
...转换为CSS时会变成这样:
div {
background: green;
}
div p {
background: red;
}
div p:hover {
background: blue;
}
div p:active {
blue;
}
Run Code Online (Sandbox Code Playgroud)
编辑:从&hover:到&:悬停
一种不太广为人知的用法是,您可以将 & 符号添加到样式的末尾,以便父选择器成为子选择器。
例如:
h3
font-size: 20px
margin-bottom: 10px
.some-parent-selector &
font-size: 24px
margin-bottom: 20px
Run Code Online (Sandbox Code Playgroud)
变成,
h3 {
font-size: 20px;
margin-bottom: 10px;
}
.some-parent-selector h3 {
font-size: 24px;
margin-bottom: 20px;
}
Run Code Online (Sandbox Code Playgroud)
您可以在此处阅读和使用更多信息
http://thesassway.com/intermediate/referencing-parent-selectors-using-ampersand