我有一个无法更改的代码:
item.left,
item.centre,
item.right{
.MIXIN();
}
.MIXIN(){
width: 100px;
}
我只需将宽度应用于 .right 元素。我只能更改 MIXIN()
的内容。我正在考虑使用 &
但它会导致 .right item.right
或 item.right .right
这不是我想要的。有没有办法使用 MIXIN()
的内容仅对 .right
元素应用样式?
最佳答案
您可以使用否定CSS伪类:not()
.
item.left,
item.centre,
item.right{
width: 20px;
&:not(.left):not(.centre) {
width: 100px;
}
}
fiddle :https://jsfiddle.net/e0nd7pk4
关于css - LESS选择器: how to apply styling only for one of the elements from inside mixin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43002919/