自定义A标签下划线动画效果

效果图演示

HTML代码

<p>Lorem ipsum dolor <a class="fancy-link" href="#">sit amet ... beatae</a>, quo iure ... consequatur.</p>

CSS样式代码

   .fancy-link {
            text-decoration: none;
            background-image: linear-gradient(red, red);
            background-repeat: no-repeat;
            background-position: bottom left;
            background-size: 0 3px;
            transition: background-size 500ms ease-in-out;
        }
        .fancy-link:hover {
            background-size: 100% 3px;
        }
        a:hover {
            color:red;
        }