We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const isSupported = window.CSS && window.CSS.supports && window.CSS.supports('--a', 0); if (isSupported) { /* supported */ } else { /* not supported */ }
/* ------------ js ------------ */getPropertyValue document.querySelector('#div').style.setProperty('--data-offset-top', card_offset_scrolltop * -1 + 'px') /* ------------ css ------------ */ transform: translateY(var(--data-offset-top)) scale(calc(480 / 420))
/* ------------ css ------------ */ :root { --body-width: 480px; } /* ------------ js ------------ */ // 方法一: document.querySelector('#div').getPropertyValue('--body-width') // 方法二: getComputedStyle(document.documentElement).getPropertyValue('--body-width') // 获取不到上面那种使用 js 动态给 css 添加的变量的值
The text was updated successfully, but these errors were encountered:
No branches or pull requests
检测浏览器是否支持 css 变量
使用 js 给 css 动态添加变量
js 获取 css 中定义的变量
The text was updated successfully, but these errors were encountered: