3 ms·
You can use CSS Variables to bridge between. var style = getComputedStyle(document.body); console.log(style.getPropertyValue('--color-font-general'));
by Chyzwar 8y ago
You can use CSS Variables to bridge between.
var style = getComputedStyle(document.body);
console.log(style.getPropertyValue('--color-font-general'));
:root { --color-font-general: #336699; }
As a bonus point, you can also change the values of CSS Variables and layout will update automatically. Take a closer look at styles of YouTube.
- tracker1 8y agoSeems like a rather ugly hack to reverse-render values out.
- Chyzwar 8y agoCSS Variables seems to be very useful for CSS. I am not sure if changing dynamically CSS variables from JS is a great idea but you have options to do so. There is more coming in project Houdini. https://developers.google.com/web/updates/2016/05/houdini#the_specifications https://developers.google.com/web/updates/2016/05/houdini#th...