<!-- html start -->
<div class="tanmer__text__background animated fadeIn delay-2s" style="--image_url: url('./images/bg.jpg')">
<h1 class="tanmer__text size__10">Hello World !</h1>
</div>
<!-- end -->
<!-- animation css -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
/* 可要可不要 */
html, body {
height: 1000px;
width: 100%;
}
/* css start */
.tanmer__text__background {
width: 100%;
height: 100%;
background-color: white;
background-size: cover;
background-position: center center;
background-attachment: fixed;
position: relative;
/* variable */
background-image: var(--image_url)
}
.tanmer__text__background .tanmer__text {
font-weight: bold;
height: 100%;
/* display flex */
display: flex;
display: -webkit-flex;
justify-content: center;
align-items: center;
/* 颜色混合,黑色透明 */
mix-blend-mode: screen;
/* variable params2 初始值 */
font-size: var(--font_size, 5vw);
background-color: var(--background_color, white);
color: var(--color, black);
}
/* end */
<!-- html start -->
<div class="tanmer__text__background animated fadeIn delay-2s" style="--image_url: url('./images/bg.jpg')">
<div class="tanmmer__position__mix__blend"></div>
<h1 class="tanmer__text size__10">Hello World !</h1>
</div>
<!-- end -->
/* tanmmer__position__mix__blend */
.tanmer__text__background .tanmmer__position__mix__blend {
position: absolute;
width: 100%;
height: 100%;
/* variable params2 初始值 */
mix-blend-mode: var(--mix_blend_mode, color-burn);
background-color: var(--background_color, #03c9a9);
}
参考文档:
https://www.youtube.com/watch?v=vs34f9FiHps&t=3783s (mix-blend-mode youtube视屏)
https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode (mix-blend-mode MDN文档)