I've been grappling with pseudo elements, but I just can't seem to make a simple button animation work using them.
My goal is to have a panel move from bottom to top on hover. Similar to the button found on this page (1st row, 2nd button).
From what I understand, adding .btn:after
will apply any CSS styles after each instance of the .btn
class. But why isn't it working in this case?
.btn {
border: 1px solid #65bb39;
color: #fff;
background-color: #65bb39;
cursor: pointer;
padding: 25px 80px;
display: inline-block;
margin: 15px 30px;
text-transform: uppercase;
outline: none;
position: relative;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.btn:after {
content: '';
position: absolute;
z-index: -1;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
border: 1px solid #65bb39;
background-color: #fff;
}
*, *:after, *:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
<div class="text">
<span class="btn">Test</span>
</div>
When hovering, I want the border to change to #65bb39
and the block to fill up with white (from bottom to top).
Any feedback on before
and after
would be greatly appreciated!