good time of day, is it possible in css to indicate in any way the style block (any number) of a particular parent, for example, simply .class{} will be searched for from html , is it really interesting to make it so that it is searched not from html , but from the specified selector? this could solve problems with integration and intersection of styles, + reducing the length of selectors
|
2 answers
What you want is implemented in sass and less . For example, in sass you can write like this:
body{ property: value; .selector1{ property: value; property: value; property: value; .selector2{ property: value; &__item1{ property: value; } } } } The same css code would look like this:
body { property: value; } body .selector1 { property: value; property: value; property: value; } body .selector1 .selector2 { property: value; } body .selector1 .selector2__item1 { property: value; } |
Yes, it is easy, indicate the parent and, after a space, its styles will be applied to all of their descendants. Demonstration:
/* применить стили к p для всех потомков .rough-parent */ .rough-parent p { color: red; } <p>Это просто параграф</p> <div class="rough-parent"> <p>Это параграф особо крутого родителя</p> </div> |