css var all in one & html & root & :root
css var all in one
number
:root{
--num: 0;
}
html{
--num: 0;
}
let html = document.querySelector(`html`);
html.style.setProperty(`--num`, `${angle}deg`);
demo
OK
https://codepen.io/xgqfrms/pen/JQVPzx
/* :root{
--num: 30;
} */
html{
/* --num: 30; */
--num: 30deg;
}
.box{
display: flex;
align-items: center;
justify-content: center;
width: 50vw;
height: 50vh;
background: #ccc;
color: #0f0;
margin: 10vh auto;
transform: rotate(var(--num));
/* transform: rotate(var(--num)deg); */
}
// https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
let log = console.log;
let html = document.querySelector(`html`);
let root = document.querySelector(`:root`);
log(`html =`, html);
let angle = 30;
let uid = setInterval(() => {
angle += 30;
html.style.setProperty(`--num`, `${angle}deg`);
// html.setProperty(`--num`, `${angle}deg`);
// html.setAttribute(`--num`, `${angle}deg`);
// root.setAttribute(`--num`, 30);
}, 1000);
setTimeout(() => {
clearInterval(uid);
}, 1000 * 10);
style.setProperty
style.setProperty(propertyName, value, priority);
https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/setProperty
style.setProperty(propertyName, value, priority);
let declaration = document.styleSheets[0].rules[0].style;
declaration.setProperty('border-width', '1px 2px');
// Equivalent to:
// declaration.borderWidth = '1px 2px';
html & root & :root
let root = document.documentElement;
root.addEventListener("mousemove", e => {
root.style.setProperty('--mouse-x', e.clientX + "px");
root.style.setProperty('--mouse-y', e.clientY + "px");
});
https://css-tricks.com/updating-a-css-variable-with-javascript/
html & :root

let html = document.querySelector(`:root`);
html.scrollHeight;
html.innerText = html.innerText.split(' ').join('');
how to change css variables in javascript
https://davidwalsh.name/css-variables-javascript
:root {
--my-variable-name: #999999;
}
getComputedStyle(document.documentElement).getPropertyValue('--my-variable-name'); // #999999
document.documentElement.style.setProperty('--my-variable-name', 'pink');
https://stackoverflow.com/questions/41370741/how-do-i-edit-a-css-variable-using-js
style.cssText
var html = document.getElementsByTagName('html')[0];
html.style.cssText = "--main-background-color: red";
style.setProperty
var html = document.getElementsByTagName('html')[0];
html.style.setProperty("--main-background-color", "green");
.setAttribute("style", "--main-background-color: green");
var html = document.getElementsByTagName('html')[0];
html.setAttribute("style", "--main-background-color: green");
touch circle menu

refs
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
css var all in one & html & root & :root的更多相关文章
- CSS3 & CSS var & :root
CSS3 & CSS var & :root How to change CSS :root color variables in JavaScript https://stackov ...
- ssh服务启动失败 /var/empty must be owned by root and not group or world-writable.
输入 /etc/rc.d/init.d/sshd start 启动sshd服务,报如下错误: /var/empty must be owned by root and not group or wor ...
- centos无法正常启动,报chown: invalid user:'root:root'
现象: 系统无法正常启动,启动界面卡在上图的位置 注意错误信息:chown: invalid user:'root:root' 原因:/etc/passwd文件损坏或者被清空 尝试:1.grub菜单项 ...
- css var & auto width css triangle
css var & auto width css triangle https://codepen.io/xgqfrms/pen/PooeEbd css var https://codepen ...
- 0 lrwxrwxrwx. 1 root root 13 Nov 20 12:44 scala -> scala-2.12.4
符号链接的文件属性相同,真正的权限属性由符号链接所指向的实际文件决定.
- Linux关闭You have new mail in /var/spool/mail/root提示
终端远程登陆Linux后经常提示You have new mail in /var/spool/mail/root 这个提示是LINUX会定时查看LINUX各种状态做汇总,每经过一段时间会把汇总的信息 ...
- Starting sshd: /var/empty/sshd must be owned by root and not group or world-writable.
Starting sshd: /var/empty/sshd must be owned by root and not group or world-writable. [FAILED] ...
- 关于Linux上的SSH服务无法启动,提示“/var/empty/sshd must be owned by root and not group or world-writable”错误
首先通过物理终端进入到linux上,手工检查ssh发现没运行# /etc/init.d/sshd statussshd is stopped 手动启动服务,发现报告权限错误.# /etc/init.d ...
- Linux出现You have new mail in /var/spool/mail/root提示,关闭邮件提示清理内容的解决方案
Linux出现You have new mail in /var/spool/mail/root提示,关闭邮件提示的解决方案 有的时候敲一下回车,就出来You have new mail in /va ...
随机推荐
- 深入理解 MySQL 索引底层原理
https://mp.weixin.qq.com/s/qHJiTjpvDikFcdl9SRL97Q
- (Oracle)DDL及其数据泵导入导出(impdp/expdp)
create tablespace ybp_dev datafile 'G:\app\Administrator\oradata\health\ybp_dev1.dbf' size 10m autoe ...
- 长连接开发踩坑之netty OOM问题排查实践
https://mp.weixin.qq.com/s/jbXs7spUCbseMX-Vf43lPw 原创: 林健 51NB技术 2018-07-13
- makefile自动生成学习
https://www.cnblogs.com/jrglinux/p/6964169.html 关键是如何写Makefile.am 其他的交给 自动工具完成 添加一个 很好的博客 学习下 https ...
- C++ Primer Plus读书笔记(七)函数
1.声明 void fun1(); //该声明在C中的意思是不指定参数,但是在C++中是指定参数为void void func2(...); //C++中不指定参数 2.函数参数为数组区间 STL有数 ...
- Node.js躬行记(6)——自制短链系统
短链顾名思义是一种很短的地址,应用广泛,例如页面中有一张二维码图片,包含的是一个原始地址(如下所示),如果二维码中的链接需要修改,那么就得发代码替换掉. 原始地址:https://github.com ...
- Vue3.0网页版聊天|Vue3.x+ElementPlus仿微信/QQ界面|vue3聊天实例
一.项目简介 基于vue3.x+vuex+vue-router+element-plus+v3layer+v3scroll等技术构建的仿微信web桌面端聊天实战项目Vue3-Webchat.基本上实现 ...
- 3.DHCP原理
1.DHCP服务器给首次接入网络的客户端分配网络参数的工作原理 只有跟DHCP客户端在同一个网段的DHCP服务器才能收到DHCP客户端广播的DHCP DISCOVER报文.当DHCP客户端与DHCP服 ...
- CCF-交通规划-dijkstra+贪心
交通规划 问题描述 G国国王来中国参观后,被中国的高速铁路深深的震撼,决定为自己的国家也建设一个高速铁路系统. 建设高速铁路投入非常大,为了节约建设成本,G国国王决定不新建铁路,而是将已有的铁路改造成 ...
- 我们到底为什么要用 IoC 和 AOP
作为一名 Java 开发,对 Spring 框架是再熟悉不过的了.Spring 支持的控制反转(Inversion of Control,缩写为IoC)和面向切面编程(Aspect-oriented ...