Answer the question
In order to leave comments, you need to log in
LESS: how to assign colors based on context?
Hey!
There is a modular system where parts of the front-end (blocks and containers) do not know anything about each other, and it is very desirable to "make friends" of them using CSS (LESS) of a specific theme without changing the HTML markup.
There is a "transparent" block in which the color of the text should change depending on the context, that is, on where this block is placed. If the container has a dark background, the text is light; if the background of the container is light, the text is dark.
The markup of the container does not contain an explicit indication of its "darkness" factor, I also want to regulate this from the styles. Ideally it should look like this:
.block {
.color_main();
}
.block2 .title {
.color_main();
}
header, footer {
.is_dark();
}
block,
.block2 .title {
color:#000;
}
header .block,
footer .block,
header .block2 .title,
footer .block2 .title {
color:#FFF;
}
Answer the question
In order to leave comments, you need to log in
You can for example like this:
.block {
color: #fff;
.title {
color: #fff;
}
header &, footer & {
color: #000;
.title {
color: #000;
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question