使视频背景变暗

ruc*_*asu 2 html css

如何使视频中的背景变暗而不影响其上的文本?

 <div class="fullscreen-bg">   
    <video loop muted autoplay poster="img/videoframe.jpg" class="fullscreen-bg__video">
        <source src="images/instituteVideo.webm" type="video/webm">
    </video>
    <div class="text-vid">
        <h2 class="texts">Transform into a Smart Institute</h2>
    </div>
</div>

.fullscreen-bg {    
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            height: 84vh;
            width: 100%;
            overflow: hidden;
            object-fit: cover;
            z-index: -99;
            position: relative;
            filter: brightness(75%);
    }

    .text-vid {
            position: absolute;
            top:10%;
     }
Run Code Online (Sandbox Code Playgroud)

这是我尝试过的,我也尝试过使用不起作用的背景颜色。使用过滤器会使背景变暗,但也会影响文本颜色

小智 8

只需添加这个 -

video {
   filter: brightness(50%);
}
Run Code Online (Sandbox Code Playgroud)


Ter*_*rry 5

只需使用放置在视频上方、文本下方的绝对定位伪元素:

.fullscreen-bg::before {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    content: '';

    /* Any overlay color that you want, here I use black with 25% opacity */
    background-color: rgba(0,0,0,0.25);
}
Run Code Online (Sandbox Code Playgroud)