Take a look at this fiddle .
It has two divs with class name wrapper_servp ,one is hidden and one is visible.
I want to target the value of the data attribute of the input that has class-name services but only of the hidden div.
In other words I want to get 26 .
Best bet is to do the hiding via a class. that way you have a CSS query for the hidden div.
.wrapper_servp.hidden .services
vs.
.wrapper_servp .services
1 Like
designtrooper:
only of the hidden div
Just like there’s a :visible
selector, there’s also a :hidden
selector. ;-)
However, using a proper utility class as @Dormilich suggests is certainly the preferable approach.
I tried using a class but it does not work…let me explain why.
I used this class:
.btypehide{display:none}//of course the name can be anything
In trying to apply it the original style prevails .
Take a look at this image snapshot from chrome dev tools:image
which of the two comes first in the definitions?
.btypehide is at line 102.
.
wrapper_servp{ display: flex;…} is at line 800 so I guess this answers your question.
Despite the above the latter takes precedence and I cannot understand why…
Because that is how Cascading Stylesheets work.
To fix that you’d have to make btypehide more specific, e.g. div.btypehide
or .wrapper_servp.btypehide
1 Like
When it comes to the following two definitions:
wrapper_servp{ display: flex;...}
.btypehide{display:none}
Isn’t the .btypehide of a higher specificity, which would give it priority over the other?
no, both are a single class (there was an unintended line break between . and wrapper_servp in the previous post)
Aha yes, so when they both have the same specificity (id trumps class, class trumps tag), the line number ordering then determines in which order they are applied. Thanks.
A useful resource: The Great Specificity Swindle
1 Like
I thought that rules that come first(earlier in the sheet take precedence)…I was wrong,it is the other way around.
thx…
by the way…that solved it…
Emgo
October 14, 2017, 4:09am
13
Rules that have the same specificity will obey the cascading pattern. Specificity overrules cascading, and Ids overrule all classes.
system
Closed
January 13, 2018, 11:09am
14
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.