Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bishoplee/23647825315ce2908ac19f7d73e325cf to your computer and use it in GitHub Desktop.
Save bishoplee/23647825315ce2908ac19f7d73e325cf to your computer and use it in GitHub Desktop.
Custom Animated Links with Psuedo Elements
<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>
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