I’ve been getting friendly with SASS as Crowd Favorite has standardized on that for our CSS pre-processing. Today I was excited to learn1 I can use variables for selectors (and for property names, etc.) as well as for property values (the common usage).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Vars – note the quotes around comma separated selectors | |
| $a-tags: 'a, a:active, a:hover, a:visited'; | |
| $a-tags-hover: 'a:active, a:hover'; | |
| // Usage | |
| #{$a-tags} { | |
| color: red; | |
| font-size: 1em; | |
| text-decoration: none; | |
| } | |
| #{$a-tags-hover} { | |
| color: blue; | |
| } |
I’m going to really like this for A tags, etc.
@alexkingorg awesome usage! Sass/compass is pretty mind blowing compared to vanilla CSS.
@alexkingorg As a side note, it’s worth including :focus in there for accessibility (and for other keyboard users). http://t.co/ioZ1SnAnY0
@alexkingorg Nope, new thought provoking hat.
Interesting concept but not really maintainable – “Sass vars for selectors” http://t.co/VsRNmJuEZh
RT @chriscoyier: you “can use variables for selectors” (in Sass) http://t.co/52Bj4m0JVv
SASS Variables for Selectors http://t.co/q6647I3e4g
Sass variables for selectors http://t.co/KCeHNEcSqV
Just learned I can use SASS variables for selectors from a blog post by @alexkingorg http://t.co/Rnxa83UPy6 #scss
“@chriscoyier: you “can use variables for selectors” (in Sass) http://t.co/URcyOIU4lf” OMG
if you’re using compass, you can also try this http://compass-style[...]raphy/links/
SASS Variables for Selectors — http://t.co/AYP9KQOz0G