Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select next element CSS

i have 2 div elements in html :

<body>
  <div id="one"></div>
  <div></div>
</body>

I want to hide div elements after div with id="one" from CSS, I tried this :

#one:after{display:none}

This doesn't work any other way to do?

like image 261
Mahender Singh Avatar asked May 09 '26 16:05

Mahender Singh


1 Answers

No, :after pseudo doesn't do that, you need to use

#one + div {
   display: none;
}

Demo

And if you want to hide ALL div followed by #one you will have to use

#one ~ div {
   display: none;
}

Demo 2

like image 118
Mr. Alien Avatar answered May 11 '26 05:05

Mr. Alien