[英]Combine multiple selectors with the same attribute selector into one selector in CSS
Is it possible in CSS/SASS/LESS to combine multiple selectors with the same attribute into one selector without repeating the attribute?在 CSS/SASS/LESS 中是否可以将具有相同属性的多个选择器组合成一个选择器而不重复该属性?
For example:例如:
div.foo[data="123"] {
color: red;
}
p.bar[data="123"] {
color: red;
}
p.bar[data="123"], div.foo[data="123"]{
color: red;
}
Combine them somehow?以某种方式组合它们? Such as this invalid scenario:
比如这个无效的场景:
(div.foo, p.bar)[data = "123"] {
color: red;
}
You could do it like that:你可以这样做:
div.foo,
p.bar {
&[data="123"] {
color: red;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.