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的更多相关文章

  1. CSS3 & CSS var & :root

    CSS3 & CSS var & :root How to change CSS :root color variables in JavaScript https://stackov ...

  2. 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 ...

  3. centos无法正常启动,报chown: invalid user:'root:root'

    现象: 系统无法正常启动,启动界面卡在上图的位置 注意错误信息:chown: invalid user:'root:root' 原因:/etc/passwd文件损坏或者被清空 尝试:1.grub菜单项 ...

  4. css var & auto width css triangle

    css var & auto width css triangle https://codepen.io/xgqfrms/pen/PooeEbd css var https://codepen ...

  5. 0 lrwxrwxrwx. 1 root root 13 Nov 20 12:44 scala -> scala-2.12.4

    符号链接的文件属性相同,真正的权限属性由符号链接所指向的实际文件决定.

  6. Linux关闭You have new mail in /var/spool/mail/root提示

    终端远程登陆Linux后经常提示You have new mail in /var/spool/mail/root 这个提示是LINUX会定时查看LINUX各种状态做汇总,每经过一段时间会把汇总的信息 ...

  7. 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] ...

  8. 关于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 ...

  9. 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 ...

随机推荐

  1. memset 在c++中使用细节注意

    C语言,在利用struct进行数据封装时,经常会使用memset(this,0,sizeof(*this))来初始化.而C++中,有时候也会用到struct,在利用memset进行初始化时,非常容易踩 ...

  2. centos7-docker的安装过程

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

  3. Codeforces 1220D 思维 数学 二分图基础

    原题链接 题意 我们有一个含多个正整数的集合B,然后我们将所有的整数,也就是Z集合内所有元素,都当做顶点 两个整数 \(i , j\) 能建立无向边,当且仅当 \(|i - j|\) 这个数属于B集合 ...

  4. 重绘和回流(Repaint & Reflow)总结,以及如何进行优化

    1. 浏览器渲染机制 浏览器采用流式布局模型(Flow Based Layout) 浏览器会把HTML解析成DOM,把CSS解析成CSSOM,DOM和CSSOM合并就产生了渲染树(Render Tre ...

  5. 项目管理/Bug管理/问题管理—Phabricator

    项目管理/Bug管理/问题管理-Phabricator 1.项目管理/Bug管理/问题管理工具 2.Phabricator 3.Docker 方式安装Phabricator 3.1Docker方式安装 ...

  6. 渗透测试工具-sqlmap

    简单来说:一个用来做sql注入攻击的工具 安装 1,下载sqlmap.zip,下载环境: 打开sqlmap官网https://github.com/sqlmapproject/sqlmap/ :下载p ...

  7. GeoMesa Java API-写入与查询数据

    GeoMesa Java API-写入与查询数据 写入数据 DataStore SimpleFeatureType SimpleFeature 写入 查询数据 几个常用查询条件 设置最大返回条目: 设 ...

  8. redis学习教程二《四大数据类型》

    redis学习教程二<四大数据类型>  四大数据类型包括:字符串    哈希    列表   集合一 : Redis字符串         Redis字符串命令用于管理Redis中的字符串 ...

  9. isEmpty isBlank 区别

    Sring test="  "; 这个 isblank 返回 true 但是 isEmpty 返回 false   所以: 一般用 isBlank 就可以了 ,是逐个字符检查 pu ...

  10. AS中的协议---IGP、EGP(BGP)

    查考文档: http://www.360doc.com/content/18/0327/23/11935121_740740341.shtml 自治系统(AS)就是指在网络中处于同一个控制下的路由器和 ...