Created
October 15, 2013 19:31
-
-
Save daphotron/6997331 to your computer and use it in GitHub Desktop.
Testing compass contrast-color() function on sassmeister.com
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
| <div class="btn-dark">Hello dark</div> | |
| <div class="btn-light">Hello light</div> | |
| <div class="btn-dark-contrast">Hello dark</div> | |
| <div class="btn-light-contrast">Hello light</div> |
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
| // ---- | |
| // Sass (v3.3.0.rc.1) | |
| // Compass (v0.13.alpha.7) | |
| // ---- | |
| @import "compass"; | |
| %btn { | |
| float: left; | |
| margin: 1em; | |
| padding: 1em; | |
| } | |
| //=========================================== | |
| // Testing color contrast functions | |
| //=========================================== | |
| $color-dark: #000; | |
| $text-light: #fff; | |
| $color-light: #ddd; | |
| $text-dark: #000; | |
| $threshold: 100%; | |
| .btn-dark { | |
| @extend %btn; | |
| background-color: $color-dark; | |
| color: contrast-color($color-dark, $text-dark, $text-light, $threshold); | |
| } | |
| .btn-light { | |
| @extend %btn; | |
| background-color: $color-light; | |
| color: contrast-color($color-light, $text-dark, $text-light, $threshold); | |
| } | |
| //=========================================== | |
| $contrasted-dark-default: #000; | |
| $contrasted-light-default: #fff; | |
| .btn-dark-contrast { | |
| @extend %btn; | |
| @include contrasted(#9dc82a); | |
| } | |
| .btn-light-contrast { | |
| @extend %btn; | |
| @include contrasted(#f1f1f1); | |
| } | |
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
| .btn-dark, .btn-light, .btn-dark-contrast, .btn-light-contrast { | |
| float: left; | |
| margin: 1em; | |
| padding: 1em; | |
| } | |
| .btn-dark { | |
| background-color: black; | |
| color: white; | |
| } | |
| .btn-light { | |
| background-color: #dddddd; | |
| color: black; | |
| } | |
| .btn-dark-contrast { | |
| background-color: #9dc82a; | |
| color: black; | |
| } | |
| .btn-light-contrast { | |
| background-color: #f1f1f1; | |
| color: black; | |
| } |
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
| <div class="btn-dark">Hello dark</div> | |
| <div class="btn-light">Hello light</div> | |
| <div class="btn-dark-contrast">Hello dark</div> | |
| <div class="btn-light-contrast">Hello light</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment