Gradient button with translate on hover
A Pen by Eric Grucza on CodePen.
<div class="button-container"> | |
<a href="#" class="btn"><span>Click Me</span></a> | |
</div> |
@import "bourbon"; | |
body, html { | |
margin: 0; | |
padding: 0; | |
height: 100%; | |
width: 100%; | |
font-family: 'Open Sans', sans-serif; | |
background-color: #17161e; | |
} | |
.button-container { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
} | |
.btn { | |
display: block; | |
height: 50px; | |
width: 186px; | |
position: relative; | |
overflow: hidden; | |
text-decoration: none; | |
text-transform: uppercase; | |
letter-spacing: 2px; | |
color: white; | |
font-size: 14px; | |
text-align: center; | |
&:after { | |
position: absolute; | |
content:''; | |
display: inline-block; | |
background: rgba(59,173,227,1); | |
background: linear-gradient(45deg, rgba(59,173,227,1) 0%, rgba(87,111,230,1) 25%, rgba(152,68,183,1) 51%, rgba(255,53,127,1) 100%); | |
height: 50px; | |
width: 372px; | |
z-index: -1; | |
transform: translateX(-280px); | |
transition: transform 400ms ease-in; | |
} | |
&:hover { | |
&:after { | |
transform: translateX(-200px); | |
} | |
} | |
span { | |
position: relative; | |
top: 16px; | |
} | |
} |