Skip to content

Instantly share code, notes, and snippets.

@jacine
Created December 29, 2011 00:57
Show Gist options
  • Save jacine/1530834 to your computer and use it in GitHub Desktop.
Save jacine/1530834 to your computer and use it in GitHub Desktop.
Fun with CSS3 gradients, animation and 3d transforms.
/**
* Fun with CSS3 gradients, animation and 3d transforms.
* Animation started with an example from @treehouse.
*/
/* Keyframes
------------------------------------------------------------------------------*/
@keyframes spin {
0% { transform: rotateY(0); }
100% { transform: rotateY(-360deg); }
}
@keyframes flip {
0% { transform: rotateX(0deg); }
100% { transform: rotateX(360deg); }
}
/* Container
------------------------------------------------------------------------------*/
html {
background-color: #d5257b;
background-image: linear-gradient(top, #d5257b, #52288d);
min-height: 100%;
}
body {
font-family: "Helvetica Neue", sans-serif;
margin: 20% auto 0 auto;
padding: 0;
perspective: 1000;
perspective-origin: 50% 75px;
transition: perspective, 1s;
}
body:hover {
perspective-origin: 50% -100px;
}
/* Boxes
------------------------------------------------------------------------------*/
ol, li {
height: 150px;
width: 150px;
}
ol {
animation: spin 10s linear 1s infinite;
color: #fff;
font-size: 7em;
margin: 0 auto;
padding: 0;
transform-style: preserve-3d; /* or "flat" */
}
li {
backface-visibility: visible; /* or "hidden" */
background: linear-gradient(rgba(0,0,0,0.6) 20%, rgba(0,0,0,0.9) 80%);
border: solid 1px #000;
border-radius: 5px;
list-style: none;
position: absolute;
text-align: center;
text-stroke: 2px #000;
}
li:nth-child(1) { transform: translateZ(300px); }
li:nth-child(2) { transform: rotateY(36deg) translateZ(300px); }
li:nth-child(3) { transform: rotateY(72deg) translateZ(300px); }
li:nth-child(4) { transform: rotateY(108deg) translateZ(300px); }
li:nth-child(5) { transform: rotateY(144deg) translateZ(300px); }
li:nth-child(6) { transform: rotateY(180deg) translateZ(300px); }
li:nth-child(7) { transform: rotateY(216deg) translateZ(300px); }
li:nth-child(8) { transform: rotateY(252deg) translateZ(300px); }
li:nth-child(9) { transform: rotateY(288deg) translateZ(300px); }
li:nth-child(10) { transform: rotateY(324deg) translateZ(300px); }
/* Numbers
------------------------------------------------------------------------------*/
span {
display: block;
animation: flip 1s ease 1;
}
li:nth-child(1) span { animation-delay: 0s; }
li:nth-child(2) span { animation-delay: 1s; }
li:nth-child(3) span { animation-delay: 2s; }
li:nth-child(4) span { animation-delay: 3s; }
li:nth-child(5) span { animation-delay: 4s; }
li:nth-child(6) span { animation-delay: 5s; }
li:nth-child(7) span { animation-delay: 6s; }
li:nth-child(8) span { animation-delay: 7s; }
li:nth-child(9) span { animation-delay: 8s; }
li:nth-child(10) span { animation-delay: 9s; }
<ol>
<li><span>1</span></li>
<li><span>2</span></li>
<li><span>3</span></li>
<li><span>4</span></li>
<li><span>5</span></li>
<li><span>6</span></li>
<li><span>7</span></li>
<li><span>8</span></li>
<li><span>9</span></li>
<li><span>10</span></li>
</ol>
{"view":"split","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment