Is it possible in CSS that when for example the class 'demo1' is display:block the class 'demo2' is automatically display:None
1 Answer
Short Answer : No
Workaround : Use Javascript or jQuery using .toggle()
If you want to stick with CSS, you can do something like
div[style*="block"] + div {
display: none;
}
The above selector will see whether div having an attribute of style contains a value called block if yes, than hide the adjacent div element using +
1 Comment
Brad Christie
Indeed, or use a higher-level class. e.g.
.hidden div.one, .hidden div.two { display: none; } then apply hidden to a container of both divs.