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
Find the containerID of tomcat and enter the toma...
Table of contents 1. Choose the most appropriate ...
Download mysql-5.7.19-winx64 from the official we...
background Today, I was browsing CodePen and saw ...
Table of contents Overview Form validation withou...
When I was writing a WeChat applet project, there...
Table of contents 1. Build using the official sca...
Table of contents 1. Page Rendering 2. Switch tag...
Disable Build Partition expressions do not suppor...
This article example shares the specific code of ...
Table of contents Overview How to make full use o...
Example: We use the Python code loop_hello.py as ...
Real-time replication is the most important way t...
1. Preparation After installing the Linux operati...
Query the MySQL source first docker search mysql ...