Animation box

animation new box

HTML

<ul>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>

<button class="btn">
нажми меня
</button>

CSS

ul {
  list-style-type: none;
  margin: 15px;
  padding: 0;
  width: 120px;
  height: 80px;
  overflow: hidden;
  position: relative;
}

li {
  width: 30px;
  height: 30px;
  background: #555;
  float: left;
  position: relative;
  margin: 5px;
  border-radius: 3px;
}

.new {
  width: 30px;
  height: 30px;
  position: relative;
  background: red;
  z-index: 101;
  
  -webkit-animation: new-element 0.2s;
  -moz-animation:    new-element 0.2s;
  -o-animation:      new-element 0.2s;
  animation:         new-element 0.2s;
}

@-webkit-keyframes new-element {
  0%   { width: 0; }
  100% { width: 30px; }
}
@-moz-keyframes new-element {
  0%   { width: 0; }
  100% { width: 30px; }
}
@-o-keyframes new-element {
  0%   { width: 0; }
  100% { width: 30px; }
}
@keyframes new-element {
  0%   { width: 0; }
  100% { width: 30px; }
}

.btn {
  font-size: 18px;
  padding: 8px 12px;
  background: green;
  border: none;
  color: #fff;
  border-radius: 0;
  margin-left: 20px;
}

JavaScript

$('.btn').click(function(){
  $('ul').prepend('<li class="new"></li>');
})