how to disabled prefers-color-scheme in js

dark theme

https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme

https://web.dev/prefers-color-scheme/#supporting-dark-mode

if (window.matchMedia('(prefers-color-scheme)').media !== 'not all') {
console.log(' Dark mode is supported');
}

https://gosink.in/javascript-css-toggle-dark-light-theme-based-on-your-users-preferred-scheme/

data-user-color-scheme

const applySetting = passedSetting => {
let currentSetting = passedSetting || localStorage.getItem(STORAGE_KEY); if (currentSetting) {
document.documentElement.setAttribute('data-user-color-scheme', currentSetting);
setButtonLabelAndStatus(currentSetting);
} else {
setButtonLabelAndStatus(getCSSCustomProp(COLOR_MODE_KEY));
}
};

https://codepen.io/xgqfrms/pen/qBbdbbJ?editors=1010

See the Pen user controlled dark mode & them toggole by xgqfrms
(@xgqfrms) on CodePen.

document.documentElement.setAttribute

https://stackoverflow.com/questions/56300132/how-to-over-ride-css-prefers-color-scheme-setting

// root/default variables
:root {
--font-color: #000;
--link-color:#1C75B9;
--link-white-color:#fff;
--bg-color: rgb(243,243,243);
}
//dark theme
[data-theme="dark"] {
--font-color: #c1bfbd;
--link-color:#0a86da;
--link-white-color:#c1bfbd;
--bg-color: #333;
}
//the redundancy is for backwards compatibility with browsers that do not support CSS variables.
body
{
color:#000;
color:var(--font-color);
background:rgb(243,243,243);
background:var(--bg-color);
}

document.documentElement.setAttribute('data-theme', 'light');

html customize element & dark theme

https://codepen.io/xgqfrms/pen/eYJBBVB

See the Pen html customize element & dark theme by xgqfrms
(@xgqfrms) on CodePen.

https://developers.google.com/web/fundamentals/performance/critical-rendering-path/render-tree-construction?hl=zh-cn

js toggle theme


xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


how to disabled prefers-color-scheme in js & dark theme的更多相关文章

  1. mac系统终端的color scheme配置和vim配置

    一.配置终端 solarized http://ethanschoonover.com/solarized 简单配置脚本: #!/bin/sh git clone git://github.com/a ...

  2. mplayer-for-windows change color scheme in win 7

    Q: When I play movie on Windows7, always comes this message: The color scheme has been changed The f ...

  3. 程序员的底色(IDE color scheme、CLI 命令行界面)

    1. IDE ⇒ Dracula(吸血鬼) IDE:PyCharm,VS2013: sublime:color scheme,Monokai: 2. CLI 命令行界面 $ setterm -inve ...

  4. css dark theme & js theme checker

    css dark theme & js theme checker live demo https://codepen.io/xgqfrms/pen/GRprYLm <!DOCTYPE ...

  5. switchable css dark theme in js & html custom element

    switchable css dark theme in js & html custom element dark theme / dark mode https://codepen.io/ ...

  6. a标签(普通标签如span)没有disabled属性 ,怎样利用js实现该属性

    a标签以及其她普通标签没有disabled属性,要想实现类似input框属性disabled可以通过css样式设置pointer-events的值来设定: <!DOCTYPE html> ...

  7. 如何为属性是disabled的表单绑定js事件

    $(document).click(function(e){ var el = e.target; if (el.tagName == 'INPUT') { $(el).removeAttr('dis ...

  8. 我的ubuntu配置

    每次装系统都是非常蛋疼的过程,新装的系统还是要配置一下的 首先安装google拼音 sudo apt-get install fcitx fcitx-googlepinyin 然后按装numix主题 ...

  9. Frontend Development

    原文链接: https://github.com/dypsilon/frontend-dev-bookmarks Frontend Development Looking for something ...

随机推荐

  1. Win+R 快速启动程序

    将某个程序的可执行C:\Program Files\Oracle\VirtualBox\VirtualBox.exe 或其快捷键 放入 某个自建的快捷键集合文件夹,可以自定义命名 如 vb 将其添加到 ...

  2. GDB查看内存命令(x命令) 用gdb查看指定地址的内存内容

    GDB查看内存命令(x命令) - super119 - 博客园 https://www.cnblogs.com/super119/archive/2011/11/18/2254382.html 可以使 ...

  3. TCP/IP中的Payload概念以及由此引申出的一些问题

    TCP报文一次性最大运输的货物量(Payload),大体可以这么来计算: IP报文头长度  +  TCP报文头长度  +  Payload长度  ≤ MTU 即左边的三者之和,要小于等于右边MTU的长 ...

  4. centos7-docker的安装过程

    一.卸载旧版本以及依赖(第一次安装忽略) sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ ...

  5. 关于js中each()使用return不能终止循环

    Jquery的each里面用return false代替break:return ture代替continue $(xx).each(function() { if(xx){ return false ...

  6. 初入Java坑,然后又入产品坑

    之前工作了一年,从事Java相关工作,不小心深得领导器重,跑去演讲.写文档.与客户沟通等,最后应公司需要,转往产品坑,坑坑相连,何时逃坑. 最近一直在学习产品经理必备工具Axure,发现这真是一个神奇 ...

  7. 算法-迪杰斯特拉算法(dijkstra)-最短路径

    迪杰斯特拉算法(dijkstra)-最短路径 简介: 迪杰斯特拉算法是由荷兰计算机科学家狄克斯特拉于1959 年提出的,因此又叫狄克斯特拉算法.是从一个顶点到其余各顶点的最短路径算法,解决的是有向图中 ...

  8. A - A Supermarket (贪心, 并查集)

    超市里有n个产品要卖,每个产品都有一个截至时间dx(从开始卖时算起),只有在这个截至时间之前才能卖出并且获得率润dy. 有多个产品,所有可以有不同的卖出顺序,每卖一个产品要占用1个单位的时间,问最多能 ...

  9. HDU-3240(卡特兰数+分解质因数后求逆元)

    卡特兰数相关公式 : \(H_n = {C_{2n}^n \over n+1)}\) \(H_n = {(4n-2)\over n+1}\times H_{n-1}\) \(H_n = C_{2n}^ ...

  10. HDOJ 1348 基本二维凸包问题

    这次写的凸包用的是Graham scan算法 就数据结构上只是简单地运用了一个栈 #include<stdio.h>#include<cmath>#include<alg ...