Skip to content

Instantly share code, notes, and snippets.

@BbsonLin
Last active December 6, 2017 01:56
Show Gist options
  • Save BbsonLin/8f67fc7ff73759fe84c3d2420b2a0ded to your computer and use it in GitHub Desktop.
Save BbsonLin/8f67fc7ff73759fe84c3d2420b2a0ded to your computer and use it in GitHub Desktop.
Animation with pseudo element
// html code
// <a href="#" class="btn btn--white">Button</a>
$color-grey-dark: #777;
$color-white: #fff;
$color-black: #000;
html {
// Let 1rem = 10px
font-size: 62.5%;
}
.btn {
&--white {
background-color: $color-white;
color: $color-grey-dark;
&::after {
background-color: $color-white;
}
}
&:link, &:visited {
text-transform: uppercase;
text-decoration: none;
padding: 1.5rem 4rem;
display: inline-block;
border-radius: 10rem;
transition: all .2s;
position: relative;
font-size: 1.6rem;
}
&:hover {
transform: translateY(-.3rem);
box-shadow: 0 1rem 2rem rgba($color-black, .2);
&::after {
transform: scaleX(1.4) scaleY(1.6);
opacity: 0;
}
}
&:active {
transform: translateY(-.1rem);
box-shadow: 0 .5rem 1rem rgba($color-black, .2);
}
&::after {
content: "";
display: inline-block;
height: 100%;
width: 100%;
border-radius: 10rem;
position: absolute;
top: 0;
left: 0;
z-index: -1;
transition: all .3s;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment