Skip to content

Instantly share code, notes, and snippets.

@0-ali
Created November 9, 2016 21:50
Show Gist options
  • Save 0-ali/79af57c398c547e138087ac6977df395 to your computer and use it in GitHub Desktop.
Save 0-ali/79af57c398c547e138087ac6977df395 to your computer and use it in GitHub Desktop.
after&before
<button class="btn-1">hover</button>
<button class="btn-2">hover</button>
<button class="btn-3">hover</button>
<button class="btn-4">hover</button>
body
{
background-color: #4CAF50;
text-align: center;
}
button
{
padding: 15px 35px;
margin: 50px 10px;
border: 3px solid #fff;
background: none;
display: inline-block;
cursor: pointer;
color: #fff;
font-size: 20px;
font-weight: bold;
text-transform: uppercase;
position: relative;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.btn-1::before,
.btn-1::after
{
content: "";
background: #fff;
position: absolute;
z-index: -1;
top: 0;
right: 0;
width:0;
height: 100%;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
button:hover{
color: #4CAF50;
}
.btn-1:hover:before
{
width: 100%;
}
.btn-2::before,
.btn-2::after
{
content: "";
background: #fff;
position: absolute;
z-index: -1;
top: 0;
left: 0;
width:100%;
height: 0;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.btn-2:hover:before
{
height: 100%;
}
.btn-3::before,
.btn-3::after
{
content: "";
background: #fff;
position: absolute;
z-index: -1;
top: 0;
left: 0;
width:0;
height: 100%;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.btn-3:hover:after
{
width: 100%;
}
.btn-4::before,
.btn-4::after
{
content: "";
background: #fff;
position: absolute;
z-index: -1;
bottom: 0;
left: 0;
width:100%;
height: 0;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.btn-4:hover:before
{
height: 100%;
}
.btn-4:hover:before
{
height: 100%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment