Last active
September 5, 2017 08:58
-
-
Save floster/53b4a0df08c8c8cec92213b6cd77ca5b to your computer and use it in GitHub Desktop.
:placeholder SASS mixin
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
@mixin optional-at-root($sel) { | |
@at-root #{if(not &, $sel, selector-append(&, $sel))} { | |
@content; | |
} | |
} | |
@mixin placeholder { | |
@include optional-at-root('::-webkit-input-placeholder') { | |
@content; | |
} | |
@include optional-at-root(':-moz-placeholder') { | |
@content; | |
} | |
@include optional-at-root('::-moz-placeholder') { | |
@content; | |
} | |
@include optional-at-root(':-ms-input-placeholder') { | |
@content; | |
} | |
} | |
/* Usage */ | |
.foo { | |
@include placeholder { | |
color: green; | |
} | |
} | |
@include placeholder { | |
color: red; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment