3
By choosing any selector definition it is possible to set styles for each element that this is defined.
My doubt would be, instead of selecting an element and changing properties for itself, I would choose to search for an element and if I find to set properties for another element with a predefined class.
In summary if .area{}
contains div .popup{}
area receives overflow: hidden
, but overflow auto
Exemplifying in HTML:
<div class="area">
<div class="popup"></div> <!-- contem entao: overflow: hidden -->
</div>
<div class="area"></div> <!-- nao contem entao: overflow: auto -->
<div class="popup"></div>
The scroll bar of div .area
depends on the div .popup
to exist.
:has or :contains
Are not validated selectors.
of course it could be controlled by JS, but I take more into account the use of stylization, or if there is a more correct way to do this is also worth.
well done,
:empty
cannot be, since, already being chosen by a class in the selector, not by "something", then it can have more elements with other classes not being the.popup
– Perco
So in this case, you wouldn’t be able to do what you want by only using css2 or css3, so you’d better do it with Javascript and jQuery.
– Yure Pereira