TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

W3C Decisions on CSS Variables (Accepting Comments)

26 pointsby bkardellalmost 13 years ago

4 comments

crazygringoalmost 13 years ago
Wow, this is very interesting that they didn't go down the LESS/SASS route of file-level "global" variables, but instead chose to bind variables to elements and their descendents themselves.<p>Coming from LESS this seemed strange at first, but upon reflection it makes a ton of sense, and provides for fantastic flexibility.<p>Now to really make this useful, we just need mathematical operators for distance values (12px - 2px) and functions like darken() and lighten() on color values... or is that being proposed somewhere too?
评论 #4391730 未加载
评论 #4391686 未加载
Kilimanjaroalmost 13 years ago
This is all I need:<p><pre><code> :root{ var-myforecolor: red; var-mybackcolor: blue; } h1{ color: $myforecolor; background: $mybackcolor; } </code></pre> This covers 80% of all cases, leaving parent-vars and cascading-vars as edge cases. Good to have them just in case.<p>Bring it on!
评论 #4391708 未加载
评论 #4391673 未加载
drivingmenutsalmost 13 years ago
I really wish they'd spend some time building a standard for how things are supposed to appear in the browser, lessening our need for normalize.css and reset.css.<p>Then, if browser makers didn't implement appearances the same way, we could point to the standard and ask why.
评论 #4391752 未加载
brynealmost 13 years ago
I'm glad $foo syntax was reserved for future flexibility in usage. When CSS level 4 is ratified in 2057, we'll all be thankful there was this kind of oversight and level-headedness now.