A Pen by designcourse on CodePen.
Created
March 19, 2022 16:20
-
-
Save bishoplee/23647825315ce2908ac19f7d73e325cf to your computer and use it in GitHub Desktop.
Custom Animated Links with Psuedo Elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="card"> | |
<h1>It's about the underline</h1> | |
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Totam, maiores. Doloribus veniam vitae mollitia similique.</p> | |
<a href="#">Take the test</a> | |
</div> | |
<div class="card"> | |
<h1>It's about the underline</h1> | |
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Totam, maiores. Doloribus veniam vitae mollitia similique.</p> | |
<a href="#">Purchase Now</a> | |
</div> | |
<div class="card"> | |
<h1>It's about the underline</h1> | |
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Totam, maiores. Doloribus veniam vitae mollitia similique.</p> | |
<a href="#">Tests</a> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background: rgb(27, 27, 32); | |
font-family: 'Poppins'; | |
margin: 0; | |
display: grid; | |
place-content: center; | |
height: 100vh; | |
} | |
.container { | |
margin: 0 4em; | |
display: flex; | |
gap: 1em; | |
} | |
.card { | |
background: rgb(255, 255, 255); | |
margin-bottom: 2em; | |
padding: 4em; | |
} | |
a { | |
color: rgb(0, 99, 228); | |
font-size: 1.3rem; | |
text-decoration: none; | |
margin-top: 1em; | |
display: inline-block; | |
font-weight: bold; | |
padding: .5em; | |
margin-left: -.5em; | |
position: relative; | |
clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%); | |
&:before, &:after { | |
position: absolute; | |
content: ''; | |
border-bottom: 3px solid rgb(0, 99, 228); | |
border-radius: 1em; | |
bottom: .3em; | |
transition: transform .5s cubic-bezier(0.075, 0.82, 0.165, 1); | |
} | |
&:before { | |
width: 1em; | |
transform-origin: left; | |
} | |
&:after { | |
width: 82%; | |
left: 1em; | |
transform: translateX(110%); | |
} | |
&:hover:before { | |
transform: scaleX(0.3); | |
} | |
&:hover:after { | |
transform: translateX(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment