Created
March 19, 2012 00:06
-
-
Save JoelBesada/2086514 to your computer and use it in GitHub Desktop.
Basic CSS States
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
/* Basic CSS States */ | |
body { | |
padding: 100px; | |
} | |
/* When a button is pressed, overwrite the transition property | |
to remove the delay, so that we can instantly change the color */ | |
.red:active ~ p.perm, .green:active ~ p.perm, .blue:active ~ p.perm { | |
transition: color 0; | |
} | |
.red:active ~ p { | |
color: red; | |
} | |
.green:active ~ p { | |
color: green; | |
} | |
.blue:active ~ p { | |
color: blue; | |
} | |
/* The large delay prevents the color from returning to its default | |
state after we've changed it with the buttons. */ | |
p.perm { | |
transition: color 0 9999999s; | |
} | |
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
<button class="red">Red</button> | |
<button class="green">Green</button> | |
<button class="blue">Blue</button> | |
<p class="temp"> | |
This text will only have the color while the button is pressed down. | |
</p> | |
<p class="perm"> | |
This text will keep the given color even after the button is released. | |
<p> |
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
{"view":"split-vertical","seethrough":"","prefixfree":"1","page":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment