2

Is it possible in CSS that when for example the class 'demo1' is display:block the class 'demo2' is automatically display:None

0

1 Answer 1

3

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;
}

Demo

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 +

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.