当前位置:网站首页>H5 embedded app adapts to dark mode

H5 embedded app adapts to dark mode

2022-07-05 06:27:00 Heerey525

situation : The project is vue It's done H5 page , It needs to be embedded in App Medium to dark mode , however H5 There needs to be a loading process , There will be a flash of white ( Rendering is not complete )
resolvent : stay public/index.html Add CSS Media query , The code is as follows

<style type="text/css">
 	 @media (prefers-color-scheme: no-preference) {
    
         body {
    
             background-color: #fff !important;
         }
     }

     @media (prefers-color-scheme: light) {
    
         body {
    
             background-color: #fff !important;
         }
     }

     @media (prefers-color-scheme: dark) {
    
         body {
    
             background-color: rgba(0,0,0,28) !important;
         }
     }
 </style>
原网站

版权声明
本文为[Heerey525]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050623068134.html