how to disabled prefers-color-scheme in js & dark theme
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.
js toggle theme

xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
how to disabled prefers-color-scheme in js & dark theme的更多相关文章
- mac系统终端的color scheme配置和vim配置
一.配置终端 solarized http://ethanschoonover.com/solarized 简单配置脚本: #!/bin/sh git clone git://github.com/a ...
- 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 ...
- 程序员的底色(IDE color scheme、CLI 命令行界面)
1. IDE ⇒ Dracula(吸血鬼) IDE:PyCharm,VS2013: sublime:color scheme,Monokai: 2. CLI 命令行界面 $ setterm -inve ...
- css dark theme & js theme checker
css dark theme & js theme checker live demo https://codepen.io/xgqfrms/pen/GRprYLm <!DOCTYPE ...
- 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/ ...
- a标签(普通标签如span)没有disabled属性 ,怎样利用js实现该属性
a标签以及其她普通标签没有disabled属性,要想实现类似input框属性disabled可以通过css样式设置pointer-events的值来设定: <!DOCTYPE html> ...
- 如何为属性是disabled的表单绑定js事件
$(document).click(function(e){ var el = e.target; if (el.tagName == 'INPUT') { $(el).removeAttr('dis ...
- 我的ubuntu配置
每次装系统都是非常蛋疼的过程,新装的系统还是要配置一下的 首先安装google拼音 sudo apt-get install fcitx fcitx-googlepinyin 然后按装numix主题 ...
- Frontend Development
原文链接: https://github.com/dypsilon/frontend-dev-bookmarks Frontend Development Looking for something ...
随机推荐
- 亿级用户下的新浪微博平台架构 前端机(提供 API 接口服务),队列机(处理上行业务逻辑,主要是数据写入),存储(mc、mysql、mcq、redis 、HBase等)
https://mp.weixin.qq.com/s/f319mm6QsetwxntvSXpKxg 亿级用户下的新浪微博平台架构 炼数成金前沿推荐 2014-12-04 序言 新浪微博在2014年3月 ...
- class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware):
class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware):
- 转载,Pandas 数据统计用法
pandas模块为我们提供了非常多的描述性统计分析的指标函数,如总和.均值.最小值.最大值等,我们来具体看看这些函数: 1.随机生成三组数据import numpy as npimport panda ...
- 前台console调试技巧
前台console调试技巧 一.console.log() 二.console.warn() 三.console.dir() 四.console.table() 五.console.assert() ...
- java日期
// 完整显示日期时间 String str = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS")).format(new Date ...
- 通过HBase Observer同步数据到ElasticSearch
Observer希望解决的问题 HBase是一个分布式的存储体系,数据按照RowKey分成不同的Region,再分配给RegionServer管理.但是RegionServer只承担了存储的功能,如果 ...
- A - 欧拉回路
欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路.现给定一个图,问是否存在欧拉回路? Input测试输入包含若干测试用例.每个测试用例的第1行给出两个正整数,分别是节点数N ...
- hdu 2089不要62 (数位dp)
Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer). 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来 ...
- Codeforces Round #651 (Div. 2) A Maximum GCD、B GCD Compression、C Number Game、D Odd-Even Subsequence
A. Maximum GCD 题意: t组输入,然后输入一个n,让你在区间[1,n]之间找出来两个不相等的数a,b.求出来gcd(a,b)(也就是a,b最大公约数).让你求出来最大的gcd(a,b)是 ...
- 递归实现jsonTree
using System;using System.Collections.Generic;using System.Text;using WeChatApi.Model;using System.L ...