Created
January 7, 2014 15:34
-
-
Save srogier/8301073 to your computer and use it in GitHub Desktop.
différence entre mixin, extend et placeholder dans sass
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
.test-placeholder-foo .ph-foo, .test-placeholder-foo .bar { | |
border: 1px solid red; | |
} | |
.test-placeholder-foo .ph-foo { | |
background: red; | |
display: block; | |
} | |
.extend-bar, .extend-foo .ext-foo, .test-extend-foo .ext-foo, .test-extend-foo .bar { | |
border: 1px solid green; | |
} | |
.extend-foo .ext-foo, .test-extend-foo .ext-foo { | |
background: green; | |
display: block; | |
} | |
.test-mixin-foo .ext-foo { | |
border: 1px solid yellow; | |
background: yellow; | |
display: block; | |
} | |
.test-mixin-foo .bar { | |
border: 1px solid yellow; | |
} |
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
///////////// PH | |
%placeholder-bar { | |
border: 1px solid red; | |
} | |
%placeholder-foo { | |
.ph-foo { | |
@extend %placeholder-bar; | |
background: red; | |
display: block; | |
} | |
} | |
.test-placeholder-foo { | |
@extend %placeholder-foo; | |
.bar { | |
@extend %placeholder-bar; | |
} | |
} | |
///////////// EXTEND | |
.extend-bar { | |
border: 1px solid green; | |
} | |
.extend-foo { | |
.ext-foo { | |
@extend .extend-bar; | |
background: green; | |
display: block; | |
} | |
} | |
.test-extend-foo { | |
@extend .extend-foo; | |
.bar { | |
@extend .extend-bar; | |
} | |
} | |
/////////////// MIXIN | |
@mixin mixin-bar { | |
border: 1px solid yellow; | |
} | |
@mixin mixin-foo { | |
.ext-foo { | |
@include mixin-bar; | |
background: yellow; | |
display: block; | |
} | |
} | |
.test-mixin-foo { | |
@include mixin-foo; | |
.bar { | |
@include mixin-bar; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment