Animated Underlined Links Made Easy in CSS

Animated Underlined Links Made Easy in CSS

CSS is a very rich tool for adding several things, including animations, colors, fonts, and much more, including animated underlines on hover. We are going to see how to easily implement this technique now. 

You will need to specifically target the element you want to add this effect to. If you were to simply target all "a" elements, every link on your site would use this effect. 

The first thing we need to do is turn off text-decoration, and set the links  to . For simplicitiy's sake, we'll also make sure the link doesn't change color on hover. Here we're applying the effect to all link elements inside our nav class:

.nav > a { position: relative; color: #000; text-decoration: none; }

.nav > a:hover { color: #000; }


Next, we want to add the border, and hide it through a transformation. We do this by inserting it with , and setting its X scale to . As a fallback, we hide it with  for browsers that don't support CSS animations:

.nav > a:before { content: ""; position: absolute; width: 100%; height: 2px; bottom: 0; left: 0; background-color: #000; visibility: hidden; -webkit-transform: scaleX(0); transform: scaleX(0); -webkit-transition: all 0.3s ease-in-out 0s; transition: all 0.3s ease-in-out 0s; }

At the very bottom we tell the element to animate all changes applied to it, with a duration of seconds. For the animation to appear, now we just need to make the element visible again on , and set its X scale back to :

.nav > a:hover:before {
visibility: visible; -webkit-transform: scaleX(1); transform: scaleX(1); }

 That's it! You can use this to target any link elements on your site. It's an amazing look! Have fun!





To view or add a comment, sign in

More articles by Jerry Schrader

  • Is your site NOT SECURE?

    Google has now implemented the Not Secure message in the browser window for ALL websites that do not have SSL setup…

  • Has Your Website Been Hijacked?

    In technology headlines these days, it's not uncommon to read about Cryptocurrency, a way for people to mine Bitcoins…

  • New Responsive Website for MRB

    Developed a new responsive website for MRB Corporate Group, built on Bootstrap, and Wordpress. It's a standard…

  • Get an edge on your competition

    With the pushing of technology and a larger part of customers coming from online these days, businesses must constantly…

  • Pet Services Website

    On my never ending quest of design and development, I have decided to put something together for pet services, (vets…

    1 Comment
  • New Lawyer Websites

    So I have been designing and developing custom lawyer websites for some time now, and decided to put together about 10…

  • Express / Node.js

    Just finished a great course using Node.js and Express.

  • New website in progress for local bar and grille

    Captain Jacks floating bar and grill has a new website in progress, I am using Angular, PHP, HTML5, CSS3, and a few…

    1 Comment
  • UX Checklist

    I had to share this, it's amazing the process that UX entails, and how many companies can overlook many of the…

  • Site mockups for new client

    Our new client, Babcock and Partners hired us, and here are the initial mockups. Desktop: Tablet: Mobile

Insights from the community

Others also viewed

Explore topics