DEV Community

Robson Muniz
Robson Muniz

Posted on

📇How to Draw Underline Link Hover Effect | HTML & CSS✏️

Lets Create a Underline Link Hover Effect using just HTML CSS, step-by-step in a very easy to follow along tutorial.



Source Code:

Markup:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Cool Underline Hover Effects</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <nav>
    <ul>
      <li><a href="#"></a>Home</li>
      <li><a href="#"></a>Services</li>
      <li><a href="#"></a>Contact</li>
      <li><a href="#"></a>About</li>
    </ul>
  </nav>

</body>

</html>
Enter fullscreen mode Exit fullscreen mode

css

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap');

*,
*::before,
*::after {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

body {
    background-color: #0a0a0a;
    color: rgb(226, 226, 226);
}

ul {
    height: 100vh;
    width: 70vw;
    min-width: 600px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    margin: auto;
}
li {
    position: relative;
    list-style: none;
    font-family: 'Poppins', sans-serif;
    color: #a0a0a0;
    font-size: 18px;
    letter-spacing: 0.5px;
    padding: 0 10px;
}

li::after {
    content: '';
    position: absolute;
    background-color: #ff3c78;
    height: 3px;
    width: 0;
    left: 0;
    bottom: -8px;
    transition: all 0.5s ease;
}

li:hover {
    color: #fff;
}
li:hover::after {
    width: 100%;
}
Enter fullscreen mode Exit fullscreen mode

🛴 Follow me on:
YouTube: https://bit.ly/3oBQbc0
Facebook: https://bit.ly/3cp2S5W
Instagram{New}: https://bit.ly/3Ihh2EB

Top comments (0)