是否可以在 2 个不同元素中混合混合文本背景剪辑和背景?

问题描述

我正在尝试在我的 html 上的背景图像和我的文本中的文本背景剪辑之间创建混合模式(基本上是不同图层上的 2 个背景图像 - 一个是背景剪辑)

我想将它们保留在不同的元素中,因为我希望图像被固定并且文本是可滚动的。

html {
    background-color: black;
    scroll-behavior: smooth;
    color: white;
}

html:before {
    position: fixed;
    background-position-y: center;
    height: 2400px;
    width: 2400px;
    content: '';
    background: url(./assets/stars.jpg);
    opacity: 100%;
    z-index: -2;

    top: -45%;
    left: -12.5%;

    -webkit-animation: spin 90s linear infinite;
    animation: spin 90s linear infinite;
}

@-webkit-keyframes spin {
    100% {
        -webkit-transform: rotate(360deg);
    }
}

@keyframes spin {
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}


#title h1 {
    font-family: Roboto Mono Medium;
    font-size: 110px;
    text-align: center;

    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;

    color: transparent;
    z-index: -2;

    background-image: url(./assets/background_animation.gif);
    background-attachment: fixed;
    background-size: 1920px 1080px;
    background-position-y: center;
    background-position-x: top;

    mix-blend-mode: difference;

    -webkit-background-clip: text;
    background-clip: text;
}
<main>
    <section id="titel">
        <div>
            <h1>Text</h1>
        </div>
    </section>
</main>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)