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

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -