html - css select a class if parent have a class -
can select somehow group of elements if class of parent changes. in these example. parent class can alertstatetrue or alertstatefalse.
<div id="parent" class="alertstatetrue"> <div class="childalertstatetrue"></div> <div class="childalertstatetrue"></div> <div class="childalertstatefalse"></div> <div class="childalertstatefalse"></div> </div> .alertstatetrue .childalertstatetrue { display: block; } .alertstatetrue .childalertstatefalse { display: none; } .alertstatefalse .childalertstatetrue { display: none; } .alertstatefalse .childalertstatefalse { display: block; }
yes, can select elements based on parents:
.a .b {} the above rule select .b elements inside .a ones.
hint
you can compress css grouping selectors have exact rules:
.alertstatefalse .childalertstatefalse, .alertstatetrue .childalertstatetrue { display: block; } .alertstatetrue .childalertstatefalse, .alertstatefalse .childalertstatetrue { display: none; }
Comments
Post a Comment