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
hint This plug-in can only be accessed under the ...
This article mainly summarizes various problems o...
Classification of website experience 1. Sensory e...
1. Dynamic parameters Starting from 2.6.0, you ca...
In the previous article, we used Docker to build ...
Commonly used JavaScript code to detect which ver...
Table of contents background analyze Data simulat...
Table of contents 1. What is reflection? 2. Refle...
Table of contents vuex persistence Summarize vuex...
Copy code The code is as follows: <html> &l...
<br />According to foreign media reports, in...
I am currently developing a video and tool app, s...
Sometimes in our actual work, we need to import d...
When nginx configures proxy_pass, the difference ...
Programmers must deal with MySQL a lot, and it ca...