Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do i make a light dark specific css tag?

Light Dark Css

body.light + .mat-medium {
  background: rgba(246,246,246,0.60);
  backdrop-filter: blur(30px) saturate(1);
}
<body class="light">
    <div class="mat-medium"></div>
</body>

I was hoping that the div would display the mat-medium class because the body had the class light but it displayed a blank div.

View the repl.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

  1. You need to fix your selector to select the div inside the body.
    You used element + element selector, which selects the first ‘div’ element that is placed immediately after ‘body’ element, but you need element > element selector to select the child ‘div’

  2. Also you need to set some width/height to the div to make it visible or add some content inside it.

body.light>.mat-medium {
  width: 100px;
  height: 100px;
  background: rgba(216, 246, 246, 0.60);
  backdrop-filter: blur(30px) saturate(1);
}
<body class="light">
  <div class="mat-medium"></div>
</body>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading