Since 2019, both Android and IOS platforms have started to use dark mode. Of course there is nothing wrong with this, but when our page is opened by the user in dark mode, they will be instantly blinded by the traditional white color. The following will briefly talk about how to make the page support dark mode. Prepare In fact, we just need to use the prefers-color-scheme media query in CSS.
illustrate
HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <title>Adapt the page to dark mode</title> </head> <body class="back"> <div class="models"><h1>Test text</h1></div> </body> </html> CSS .back {background: white; color: #555;text-align: center} @media (prefers-color-scheme: dark) { .back {background: #333; color: white;} .models {border:solid 1px #00ff00} } @media (prefers-color-scheme: light) { .back {background: white; color: #555;} .models {border:solid 1px #2b85e4} } The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: MySQL uses custom sequences to implement row_number functions (detailed steps)
>>: Using css-loader to implement css module in vue-cli
Hyperlink, also called "link". Hyperlin...
Last time, we came up with two header layouts, on...
Recently I want to use goaccess to analyze nginx ...
This article shares the specific code for JavaScr...
Vue routing this.route.push jump page does not re...
In Linux operation and configuration work, dual n...
Attribute check-strictly The official document pr...
Background Replication is a complete copy of data...
1. System environment [root@localhost home]# cat ...
Tomcat server is a free and open source Web appli...
Previously, I introduced several ways to achieve ...
This article uses examples to illustrate the prin...
Sometimes it is necessary to perform simple verif...
This article example shares the specific code for...
To obtain the calculated style in a CSS element (t...