CSS 文字特效

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <!--<video class="" src="https://13miki.cdn.bcebos.com/aa%2Fparticles.mp4" initial-time="0" muted=""  loop="loop">无法加载视频请下载到本地-->


    </video>
    <h2>
        <span>P</span>
        Articles Di
        <span>st</span>
        ortion Effects
    </h2>


</body>
</html>

CSS

*{
    padding: 0;
    margin: 0;
}
body{
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background:#000;
}
h2{
    position: relative;
    margin:20px 0 0;
    font-size: 4em  ;
    font-weight: 900;
    color: #fff;
    z-index: 1 ;
    overflow: hidden;
}
h2 span::before{
    content: '';
    position: absolute;
    left: 120%;
    width: 120%;
    height: 100%;
    background:linear-gradient(90deg ,transparent 0%,#000 5%, #000 100%) ;
    animation: animate 5.3s linear forwards infinite;
    animation-delay: 2s;
}
@keyframes animate{
    0%{
        left: 110%;
    }
    100%{
        left: -20%;
    }
}
h2 span{
    color: #ff022c;
}
video{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
    pointer-events: none;
    mix-blend-mode: screen;
}

 

点赞