前言
这个是转载自他人博客,我只是纯粹的从它的代码学习一些东西,然后给大家讲解下!
原文
代码
<video src="https://klxxcdn.oss-cn-hangzhou.aliyuncs.com/histudy/hrm/media/08reverse.mp4" autoplay muted></video>
<h2><span>We</span> must uni<span>te a</span>gainst COVID-19</h2>
* {
margin: 0;
padding: 0;
font-family: 'Poppins', sans-serif;
}
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: #000;
}
h2 {
position: relative;
font-size: 3.4em;
font-weight: 900;
color: #fff;
z-index: 1;
overflow: hidden;
margin: 20px 20px 0 0;
}
h2 span {
color: #ff022c;
}
/*这里是做为文字的遮挡层,加一个从左到后的动画就可以实现文字逐渐出现的效果*/
h2::before {
content: '';
position: absolute;
left: -20%;
width: 120%;
height: 100%;
background: linear-gradient(90deg, transparent 0%, #000 5%, #000 100%);
animation: animate 5.5s linear forwards;
animation-delay: 2s;
}
@keyframes animate {
0% {
left: -20%;
}
100% {
left: 110%;
}
}
video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
z-index: 2;
pointer-events: none;
/*这里注意一下文字是在video的下面,要能对文字进行操作的话就需要设置上面那个属性*/
mix-blend-mode: screen;
/*screen 滤色*/
}