7

One line of CSS to add basic dark/light mode

 2 years ago
source link: https://christianheilmann.com/2022/06/20/one-line-of-css-to-add-basic-dark-light-mode/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

One line of CSS to add basic dark/light mode

Monday, June 20th, 2022 at 11:33 pm

When you have your OS set up in dark mode seeing bright form elements is grating. By starting your style sheet with a single line of CSS, you can make sure that people using dark mode get dark form elements and backgrounds and those using light mode, light ones.

Codepen showing the difference the line of CSS makes - offering the page in a dark and light mode

You can see it in this codepen

You can also use the browser developer tools to simulate the different modes to see the difference.

Emulating different modes in browser developer tools

Read more about color-scheme on the MDN web docs.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK