Skip to content

Instantly share code, notes, and snippets.

@alexmwalker
Created March 22, 2012 07:03
Show Gist options
  • Select an option

  • Save alexmwalker/2156775 to your computer and use it in GitHub Desktop.

Select an option

Save alexmwalker/2156775 to your computer and use it in GitHub Desktop.
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
/* The large delay prevents the color from changing */
* { position:relative;}
ol li{
top:1.2em
}
ol{ list-style:none;
font-size:24px;
outline:1px dashed red;
height:1em;
overflow:hidden}
p.perm {transition: left 0s 4s;
}
/* When a button is pressed, overwrite the transition property
to remove the delay, so that we can instantly change the color */
.red:hover ~ p.perm, .green:hover ~ p.perm, .blue:hover ~ p.perm, .purple:hover ~ p {
transition: left 0s;
}
.red:hover ~ p {
left: 2em;
}
.green:hover ~ p {
left: 3em;
}
.blue:hover ~ p {
left: 4em;
}
.purple ~ ol li{
animation-delay:0;
animation:
score1 9s 1 linear;
animation-play-state:running;
}
.purple:hover ~ ol li{
animation:
score2 9s 1 linear;
animation-delay:10;
animation-play-state:p;
}
@keyframes score1
{
0% {background: red;top:1.2em}
1% {background: yellow;top:0em}
100% {background: yellow;top:0em}
}
@keyframes score2
{
0% {background: green;top:0em}
1% {background: yellow;top:-1.2em}
100% {background: yellow;top:-1.2em}
}
<!-- content to be placed inside <body>…</body> -->
<button class="red">Red</button>
<button class="green">Green</button>
<button class="blue">Blue</button>
<p>
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>
<button class="purple">Purple</button>
<p>
This text will only have the color while the button is pressed down.
</p>
<ol id="pl1">
<li>0</li>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ol>
<div id="char">sd</div>
{"view":"split","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment