Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
CSS backdrop-filter works only if you DON'T set background-color to transparent

I've got a greyscale backdrop-filter applied to a .cover behind one of my overlaid menus. It always has a background color, but when it is .on I sometimes, with JavaScript, want to set the .cover's background-color to an opaque black to darken the background, too.

I have the following CSS being applied to the cover:

body {
    --darkMode: transparent;
}
.cover {
    background-color: #123456;
}
.cover.on {
    -webkit-backdrop-filter: grayscale(100%);
    backdrop-filter: grayscale(100%);
    background-color: var(--darkMode); /* Notable Line */
}

The JavaScript that sets the --darkMode variable is just document.body.style.setProperty("--darkMode", "rgba(0, 0, 0, 0.5)");

However, when darkMode is not enabled, and therefore the .cover's background-color is transparent just like default, the backdrop-filters don't work at all.

You can play around with this with this fiddle.

Thanks for any insights you might have, and have a splendid day, person who was willing to read this question.

EDIT 1: My apologies, the above code was not complete; I have updated to reflect my code more directly, and have added a JS fiddle so you can see it yourself.

EDIT 2: Turns out a solution is to just set the background-color to something like rgba(0, 0, 0, 0.01) instead of transparent.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!