r/csshelp • • Oct 29 '20

Request dark mode for my website

good evening guys. does any one have a 100 percent working code that automatically turns my website into dark mode .

6 Upvotes

6 comments sorted by

2

u/TheMartinG Oct 30 '20

I made a whole different set of css styles for dark mode. I wanted it to automatically be dark mode at night time

Then I used a small js script to check for the time of day, and grab one css file or the other based on the times I had chosen

0

u/cs-063 Oct 30 '20

can you share code

2

u/TheMartinG Oct 30 '20

Nope. What you're asking for isn't a one-size-fits-all solution. Needs to be done custom.

6

u/Kthulu666 Oct 29 '20

Nope. What you're asking for isn't a one-size-fits-all solution. Needs to be done custom.

2

u/aydgn Oct 29 '20

Force your visitors to use Dark Reader extension.

https://darkreader.org

1

u/PopeFrancisLegit Oct 29 '20

You can start by using this code that inverts all colors on the webpage:

body {
filter: invert();
}

You will probably want to keep the colors on images etc., which can be done by inverting them back:

img, .some-class {
filter: invert();
}