我有两种类型的圈子,一种在.poi.licensed
内,另一种在.poi.unlicensed
内。我正在努力使.circle
内的.poi.unlicensed
有一个$tangerine
边框而不是$turqoise
。在这种情况下,我怎样才能使用尾随的amerpsand。请记住,我排除了很多其他不相关的scss,所以它必须保持这种一般结构。
我正在尝试以下方面的内容,但它会编译为.unlicensed #licensed-v-unlicensed .poi .circle {}
$turqoise: #40e8e3;
$tangerine: #ffa975;
#licensed-v-unlicensed {
.poi {
.circle {
border: 5px solid transparentize($turqoise, 0.1);
.unlicensed & {
border: 5px solid transparentize($tangerine, 0.1);
}
@include breakpoint(medium up) {
border-width: 10px;
}
border-radius: 50%;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.4);
width: 100%;
height: 100%;
position: relative;
cursor: pointer;
}
}
}
答案 0 :(得分:0)
我最终使用了我在blog上找到的技巧,即使用@at-root
从根开始并定位.unlicensed
类。这比我希望做的工作多得多,但迄今为止发现的唯一解决方案。
$turqoise: #40e8e3;
$tangerine: #ffa975;
#licensed-v-unlicensed {
.poi {
.circle {
border: 5px solid transparentize($turqoise, 0.1);
@at-root #licensed-v-unlicensed .poi.unlicensed .circle {
border: 5px solid transparentize($tangerine, 0.1);
}
@include breakpoint(medium up) {
border-width: 10px;
}
border-radius: 50%;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.4);
width: 100%;
height: 100%;
position: relative;
cursor: pointer;
}
}
}