Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide div conditionally with only CSS?

I currently use Javascript to hide my social media buttons on the main page of my Tumblr site. It's programmed to hide them only on the main page based on the url in the browser, not on any other pages.

However, I'm curious as to if there's a way to do this with just CSS (or even CSS3), similar to how media screen can make conditions for divs based on browser size. I know you can have more conditions with PHP, but Tumblr won't allow it.

like image 512
user1438432 Avatar asked Jun 09 '26 21:06

user1438432


1 Answers

Depending on the Browser size you can hide ,for example

@media (min-width: 768px) and (max-width: 979px) {
  .hidden {
    display:none;
  }
}

or

depending on the parent class

 <body class="wrapper">

 .wrapper .hidden{display:none;}
like image 68
Prashobh Avatar answered Jun 12 '26 11:06

Prashobh