titi
titi

Reputation: 91

Create an if statement with css

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

Upvotes: 2

Views: 2653

Answers (1)

Mr. Alien
Mr. Alien

Reputation: 157314

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 +

Upvotes: 3

Related Questions