[英]SCSS multiple selectors
Hi i have this code: 嗨我有这个代码:
.navbar .nav-pills .active > a {
background-color: $NavBgHighlight;
color: $NavTxtColor;
}
.navbar .nav-pills .active > a:hover {
background-color: $NavBgHighlight;
color: $NavTxtColor;
}
I wanted to merge both of the sections into one section, something more like: 我想将两个部分合并为一个部分,更像是:
.navbar .nav-pills .active > a, a:hover {
background-color: $NavBgHighlight;
color: $NavTxtColor;
}
But it doesnt work that way :( how can i merge both of them? ( I want that the :hover and the normal a will act the same) 但它不会那样工作:(我怎么能合并它们?(我想要的是:悬停和正常的a会起作用)
You can use SASS selector nesting : 您可以使用SASS选择器嵌套 :
.navbar .nav-pills .active {
> a, > a:hover {
background-color: $NavBgHighlight;
color: $NavTxtColor;
}
}
Which compiles to: 编译为:
.navbar .nav-pills .active > a, .navbar .nav-pills .active > a:hover {
...
}
.navbar{
&.nav-pills{
&.active {
> a, > a:hover {
background-color: $NavBgHighlight;
color: $NavTxtColor;
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.