<section class="sec">
<video autoplay muted loop>
<source src="./video.mp4" type="video/mp4" />
video>
<h2>Runh2>
<div class="dot">div>
section>
.sec h2 {
position: absolute;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 20vw;
color: #fff;
background: #000;
user-select: none;
font-weight: 800;
text-transform: uppercase;
text-align: center;
mix-blend-mode: multiply;
}
.sec.active h2 {
color: #000;
background: #fff;
}
.sec video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
实现上述效果后,我们进行点击切换主题后我们的切换效果是在如下两个效果之间切换。
mix-blend-mode
属性在上述的代码基础上我们只要添加一个属性,就会变成另外一个效果。
.sec.active h2 {
color: #000;
background: #fff;
mix-blend-mode: screen;
}
添加如上代码后,我们点击切换主题后我们只是修改背景颜色,而视频的内容一直保持与文字相融合。