BIJAN ROY
BIJAN ROY

Reputation: 101

How To Prevent Darkmode.js from making background-image negative

I found darkmode.js (darkmodejs.learn.uno) a really easy way to implement dark mode in my website and it works superb with me expect a small problem. Which is, it changing the color of my background-image css property and making it a kind of negetive.

Is there any way to exclude the background-image from changing its color?

Hope for reply soon.

Thanks For Help In Advance.

Upvotes: 0

Views: 1187

Answers (1)

bkis
bkis

Reputation: 2587

Yes, there is. The documentation says you can override styles.

As the library will add a class darkmode--activated to the body of your page, you can write CSS selectors matching your background in enabled dark-mode:

.darkmode--activated #my-element-with-background {
    filter: invert(0);
}

Please be aware that I don't know how exactly darkmode.js inverts you background. filter: invert(1); was just a wild guess. You'll have to examine what happens there and override the style property.

Upvotes: 2

Related Questions