hover box-shadow with no repaint
by jorgeluis
HTML
<p>Animate box-shadow without repaint</p>
<button type="button">Hover</button>
<button type="button">Over</button>
<button type="button">Us</button>
CSS
/* thanks to http://tobiasahlin.com/demo/animate-box-shadow/ */
body {
background: #eadda9;
}
button {
display: inline-block;
position: relative;
top: 0;
background-color: rgb(0,100,200);
color: #fff;
width: 150px;
height: 150px;
margin: 10px;
border: 0;
border-radius: 5px;
font-size: 1em;
box-shadow: 0 2px 2px rgba(100,30,145,0.6);
position: relative;
-webkit-transform: translateY(0);
-webkit-transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}
button:after {
content: "";
border-radius: 5px;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
box-shadow: -2px 2px 5px rgba(100,80,145,0.6);
opacity: 0;
-webkit-transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}
button:hover {
color: #fff;
background-color: rgb(10,140,200);
top: -4px;
}
button:hover:after {
opacity: 1;
box-shadow: -12px 12px 20px rgba(100,30,145,0.3);
}