Skip to content

Instantly share code, notes, and snippets.

@huffn
Created August 29, 2012 22:12
Show Gist options
  • Save huffn/3519550 to your computer and use it in GitHub Desktop.
Save huffn/3519550 to your computer and use it in GitHub Desktop.
Simple square CSS animation inspired by mr. div's gif animations (http://mrdiv.tumblr.com/)
<div class="container">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
<div class="square">
<div class="square black">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
/*
* Webkit browsers still have the smoothest rendering
* for CSS rotation animations, so this pen is best
* viewed in Chrome or Safari.
*/
html{
background: black;
height: 100%;
position: relative;
}
.container{
height: 300px;
width: 300px;
position: absolute;
top: 50%;
left: 50%;
margin: -150px 0 0 -150px;
}
.square{
height: 94%;
width: 94%;
background: white;
position: absolute;
top: 50%;
left: 50%;
margin: -47% 0 0 -47%;
}
.black{
background: black;
-webkit-animation: rotate 10s infinite linear;
-moz-animation: rotate 10s infinite linear;
-ms-animation: rotate 10s infinite linear;
-o-animation: rotate 10s infinite linear;
animation: rotate 10s infinite linear;
}
@-webkit-keyframes rotate{
0%{ -webkit-transform: rotate(0deg); }
100%{ -webkit-transform: rotate(360deg); }
}
@-moz-keyframes rotate{
0%{ -moz-transform: rotate(0deg); }
100%{ -moz-transform: rotate(360deg); }
}
@-ms-keyframes rotate{
0%{ -ms-transform: rotate(0deg); }
100%{ -ms-transform: rotate(360deg); }
}
@-o-keyframes rotate{
0%{ -o-transform: rotate(0deg); }
100%{ -o-transform: rotate(360deg); }
}
@keyframes rotate{
0%{ transform: rotate(0deg); }
100%{ transform: rotate(360deg); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment