Created
March 19, 2012 20:17
-
-
Save nicolechung/2126495 to your computer and use it in GitHub Desktop.
LESS vs CSS
This file contains 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
/* less file */ | |
.my_mixin { | |
display: block; | |
text-indent: -9999em; | |
background-color: transparent; | |
background-position: 0 0; | |
background-repeat: no-repeat; | |
overflow: hidden; | |
} | |
h1 a, .pagination em, .cog a { | |
.my_mixin | |
} | |
/* css file */ | |
.my_mixin { | |
display: block; | |
text-indent: -9999em; | |
background-color: transparent; | |
background-position: 0 0; | |
background-repeat: no-repeat; | |
overflow: hidden; | |
} | |
h1 a, .pagination em, .cog a { | |
display: block; | |
text-indent: -9999em; | |
background-color: transparent; | |
background-position: 0 0; | |
background-repeat: no-repeat; | |
overflow: hidden; | |
} |
Oh I see what you mean now, like:
http://stackoverflow.com/questions/7557626/less-js-redudancy-in-css-use-of-mixins-instead-of-selector-inheritance
The above post makes me want to try out @extend in SaSS/Compass:
http://awardwinningfjords.com/2010/07/27/sass-extend-introduction.html
Yes!! Me too. Seems to solve the problem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sure, my point is that the style of writing I interpreted LESS to encourage is not to group selectors with similar styles and instead turn repeated styles into mixins early-on in development, then adding the mixin to the appropriate declaration right then and there as you write your styles. So mixins take the place of grouping global styles. Image-replacement is an extreme example. In my next LESS project, I wont embed image-replacement into declarations, I'll stay traditional with it...I'll try to keep my mixins to less than 3 properties to avoid code-bloat.
I wrote things like
(line 20 of LESS file) h1 a { .ir; position: relative; margin-bottom: 20px; }
(line 540 of LESS file) .pagination em { .ir; position: absolute; top: 10px; right: 0; }
(line 800 of LESS file) .cog a { .ir; position: absolute; bottom: 0; left: 10px; }
instead of grouping as you provided in your example.