JSFiddle - React, Tailwind, and code Playground
by tjerabek
HTML
<div class="a">3</div>
CSS
body{
padding: 50px;
}
.num,
.init,
.a{
width: 30px;
height: 30px;
}
.a{
border: 1px solid #D7D7D7;
color: #666;
font-weight: bold;
font-family: Arial;
background-color: #F8F8F8;
background-image: -webkit-linear-gradient(top,#FEFEFE,#F8F8F8);
background-image: -moz-linear-gradient(top,#FEFEFE,#F8F8F8);
background-image: -ms-linear-gradient(top,#FEFEFE,#F8F8F8);
background-image: -o-linear-gradient(top,#FEFEFE,#F8F8F8);
background-image: linear-gradient(top,#FEFEFE,#F8F8F8);
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
font-size: 12px;
animation: myfirst 3000ms infinite;
-moz-animation: myfirst 3000ms infinite; /* Firefox */
-webkit-animation: myfirst 3000ms infinite; /* Safari and Chrome */
-o-animation: myfirst 3000ms infinite; /* Opera */
animation-delay: 1s;
-moz-animation-delay: 1s;
-webkit-animation-delay: 1s;
animation-timing-function: ease-in-out;
-moz-animation-timing-function: ease-in-out;
-webkit-animation-timing-function: ease-in-out;
}
.num,
.init{
text-align: center;
line-height: 30px;
}
.init{
display: none;
}
.a{
overflow: hidden;
}
.row{
position: relative;
-webkit-transition: all 500ms ease-in-out;
-moz-transition: all 500ms ease-in-out;
-ms-transition: all 500ms ease-in-out;
-o-transition: all 500ms ease-in-out;
transition: all 500ms ease-in-out;
}
@keyframes myfirst
{
0% {margin-top: 0}
10% {margin-top: -5px;}
20% {margin-top: 5px;}
30% {margin-top: 0;}
100% {margin-top: 0;}
}
@-moz-keyframes myfirst /* Firefox */
{
0% {margin-top: 0}
10% {margin-top: -5px;}
20% {margin-top: 5px;}
30% {margin-top: 0;}
100% {margin-top: 0;}
}
@-webkit-keyframes myfirst /* Safari and Chrome */
{
0% {margin-top: 0}
10% {margin-top: -5px;}
20% {margin-top: 5px;}
30% {margin-top: 0;}
100% {margin-top: 0;}
}
@-o-keyframes myfirst /* Opera */
{
0% {margin-top: 0}
10% {margin-top: -5px;}
20% {margin-top: 5px;}
30%...
CoffeeScript
$('.a').each ->
$this = $ @
val = $this.text()
$row = $ '<div class="row"></div>';
$this.wrapInner '<div class="init">'
$this.append $row
for num in [0..val]
$row.append '<div class="num">'+num+'</div>'
$row.css('margin-top', '-' + ($row.height() - 30)+'px')