Text Link on Hover phần 1 (ok)

https://css-tricks.com/4-ways-to-animate-the-color-of-a-text-link-on-hover/

Ví dụ 1:

<!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>Document</title>
</head>

<body>
    <a href="#" data-hover="Lorem ipsum dolor sit amet consectetur adipisicing elit. Delectus, a.">Lorem ipsum dolor sit amet consectetur adipisicing elit. Delectus, a.</a>
    <style>
        a {
            position: relative;
            display: inline-block;
            outline: none;
            color: #000;
            text-decoration: none;
            letter-spacing: 1px;
            font-weight: 400;
            text-shadow: 0 0 1px rgb(255 255 255 / 30%);
            font-size: 1.35em;
        }
        
        a::before {
            position: absolute;
            top: 50%;
            left: 0;
            overflow: hidden;
            max-width: 0;
            white-space: pre;
            border-bottom: 2px solid blue;
            color: red;
            content: attr(data-hover);
            -webkit-transition: max-width 0.5s;
            -moz-transition: max-width 0.5s;
            transition: max-width 0.5s;
            transform: translateY(-50%);
        }
        
        a:hover::before {
            max-width: 100%;
        }
    </style>
</body>

</html>

Ví dụ 2:

Ví dụ 3:

Last updated

Was this helpful?