Skip to content

Instantly share code, notes, and snippets.

@deenoize
Created December 20, 2015 12:15
Show Gist options
  • Save deenoize/0c70544547983f8c956e to your computer and use it in GitHub Desktop.
Save deenoize/0c70544547983f8c956e to your computer and use it in GitHub Desktop.
The fastest realization of box-shadow property animation with pseudo-element
.box {
position: relative;
display: inline-block;
width: 100px;
height: 100px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
border-radius: 5px;
-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);
}
.box:after {
content: "";
border-radius: 5px;
position: absolute;
z-index: -1;
top: 0;
left: 0;
width: 100%;
height: 100%;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
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);
}
.box:hover {
-webkit-transform: scale(1.25, 1.25);
transform: scale(1.25, 1.25);
}
.box:hover:after {
opacity: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment