Access our premium support and let us know your problems, we will help you solve them.

0
No products in the cart.

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: How to toggle many css styles to make a dark mode? #10065
    blanksean-kendle
    Participant

    Just add the class dark-mode to your body tag with JavaScript, then define all your dark styles with .dark-mode in front of them, like this:

    a {
        color: #330033; /* or whatever dark color */
    }
    
    .dark-mode a {
        color: white; /* or whatever light color */
    }
    

    For more info on CSS specificity and cascading, see this page:

    https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity

    I recommend grouping all dark mode styles together with a comment above them, like this /* Dark mode styles: */, and put them toward the bottom of your stylesheet (above any responsive breakpoints), so they’re together, and they’re after your regular styles – because CSS takes the last defined style (hence, cascading). That way you don’t run into problems with re-defining styles. Make sure all overriding styles have more specificity than the ones they’re attempting to override. Try to avoid use of !important where possible.

Viewing 1 post (of 1 total)