Answer the question
In order to leave comments, you need to log in
Tricky CSS selector?
There is HTML like this:
[DIV CLASS="SHOW-1"]
[DIV CLASS="SHOW-1"]1[/DIV]
[DIV CLASS="SHOW-2"]2[/DIV]
[DIV CLASS=" SHOW-3"]3[/DIV]
[DIV CLASS="SHOW-4"]4[/DIV]
[/DIV]
Is it possible to write such a CSS2 rule that ONLY DIV.SHOW-1 would be displayed with the given structure, i.e. .e. "one". If you change the class to .SHOW-2 for the outer div, then only 2 will be shown. At the same time, the selector would not depend on the number and names of children, but show only the child class of which matches the parent's class. When generating, it is not known how many children it will have.
UPD: please read the question very important. Especially the last sentence.
Answer the question
In order to leave comments, you need to log in
Sorry, this certainly does not solve your problem, just a minute of time and a desire to check something stood out. As s0rr0w already said :
Selectors with dynamic names are against the intent of CSS.But the latest browsers allow us to create css rules through javascript . Result: jsfiddle .
Selectors with dynamic names are against the intent of CSS. Use JS or backend
In css2 - definitely nothing, only JS. If js can still be used, I can throw in a script (there are a couple of lines)
.show div { display: none }
.show-1 .show-1 { display: inline }
.show-x .show-x { display: inline }
The first div has two classes: [DIV CLASS="show SHOW-1"] (the first one to hide everything, the second to show the one you need)
if you are too lazy to give two classes to the first, then this:
.show-1 div { display: none }
.show-1 .show-1 { display: inline }
.show-2 div { display : none }
.show-x .show-x { display: inline }
This is just a theory, I haven't tested it =) but it should work
And what for?
If you look in the direction of how nested menus are made, then there is no need for such tricky .. intricate designs - everything is done through the nesting of subordinate blocks and control through: hover or .active Explain?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question