所以我有这个HTML标记
<div class="text-white">
<div class="textClass"></div>
</div>
该类有一个较少定义的变量textClass
,它将标题颜色变成黑色,但是我想要的是,如果textClass
元素有一个text-white
父元素,那么textClass
标题颜色就会变成白色。这可能吗?
到目前为止,这是我目前无法使用的内容:
//I defined the color of the heading
@heading-color: black;
//My attempt to redefine the heading-color base on class
.text-white > .textClass {
@heading-color: white;
}
如果这不可能,那么我该如何用更少的精力实现这一目标呢?
感谢您提供的任何帮助。
在这种情况下,您可以在变量-
内部命名而不包含字符,如下所示:
@headingColor: black;
.text-white > .textClass {
@headingColor: white;
background-color: @headingColor;
}
.some-heading {
background-color: @headingColor;
}
输出:
.text-white > .textClass {
background-color: #ffffff;
}
.some-heading {
background-color: #000000;
}
注意:覆盖它时,可以在范围内使用它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句