Why I'm Excited About Native CSS Variables
11–20 of 33 posts
Re: Why I'm Excited About Native CSS Variables
#12Does this mean we can now also use expressions such as (pseudocode) "height: (x+1-y)px"?
Re: Why I'm Excited About Native CSS Variables
#13> In fact, I think it’s confusing to call them variables at all. They’re actually CSS properties, which gives them an entirely different set of capabilities and allows them to solve an entirely different set of problems. I think this is the problem people have with them - they don't try to be a good solution to the problem people actually have. A better designed solution would have the most common case simple and ele…
CSS Variables have been in Firefox for a year and a half now, and I’ve been using them in my own projects for at least a year, while I’m producing the thing in the first place—then when I have it as I like it, if it’s not purely for me, I rewrite it for inferior browsers (though I believe I could use something like PostCSS instead; I just haven’t). They really are a marvellous thing; my favourite example would be the…
Re: Why I'm Excited About Native CSS Variables
#14Re: Why I'm Excited About Native CSS Variables
#15JavaScript has shown us the value of designing new features in a way that they can be polyfilled or emulated via a preprocessor, so that features can gain adoption without developers having to wait for older browsers to die.
CSS variables were overdesigned in a way that makes this upgrade path impossible.
Re: Why I'm Excited About Native CSS Variables
#16Being able to manipulate these from JS would be great. Then compile-to-js languages (Clojurescript & Elm) can use their (better) programming model for styles as well.
You can reference one line of JS in your CSS style, and the returned value is what is output in your CSS at the time the (responsive) style applies. This value can be a Js variable set elsewhere on the page, the output of a function, or a string or single line of JavaScript that is evaluated in-place.
The var() feature is new and only in the v1.0.0 branch right now, but to read about the other features of this plugin check out https://github.com/eqcss/eqcss and http://elementqueries.com
Re: Why I'm Excited About Native CSS Variables
#17What I am most excited about is manipulating these using javascript, which is also something you cannot do with a CSS processor because the values are baked into the CSS.
Re: Why I'm Excited About Native CSS Variables
#18> In fact, I think it’s confusing to call them variables at all. They’re actually CSS properties, which gives them an entirely different set of capabilities and allows them to solve an entirely different set of problems. I think this is the problem people have with them - they don't try to be a good solution to the problem people actually have. A better designed solution would have the most common case simple and ele…
CSS Variables have been in Firefox for a year and a half now, and I’ve been using them in my own projects for at least a year, while I’m producing the thing in the first place—then when I have it as I like it, if it’s not purely for me, I rewrite it for inferior browsers (though I believe I could use something like PostCSS instead; I just haven’t). They really are a marvellous thing; my favourite example would be the…
Anything with preprocessors is tedious and painful, yet I've been hand-writing fluidly responsive layouts for years without predefined 'breakpoint' jumps in the design. What is it about CSS variables that allowed you to change your style?
Re: Why I'm Excited About Native CSS Variables
#19The author lists all the ways CSS variables are better than preprocessor variables. But that is the same reason that the design is flawed. JavaScript has shown us the value of designing new features in a way that they can be polyfilled or emulated via a preprocessor, so that features can gain adoption without developers having to wait for older browsers to die. CSS variables were overdesigned in a way that makes this…
Funny you should mention that, I have such a polyfill to introduce Element Query syntax to all browsers IE8 and up, and one of the features we just added was the ability to use variables in your CSS supplied from JavaScript running on the page.
Demo: http://codepen.io/tomhodgins/pen/MKWOWW
Oh, and we also added a $parent selector to CSS, just for giggles :)
http://github.com/eqcss/eqcss < it's under MIT so feel free to use it and build on it
Re: Why I'm Excited About Native CSS Variables
#20What I am most excited about is manipulating these using javascript, which is also something you cannot do with a CSS processor because the values are baked into the CSS.
While it'll be fun to manipulate CSS properties using JS values, it doesn't seem necessary.