ruchika vasu
ruchika vasu

Reputation: 111

Darken Video Background

How to Darken Background in a video without affecting the text over it?

 <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%;
     }

This is what i have tried , i have also tried using background-color which doesn't work. Using filter darkens the background , but also affects the text color

Upvotes: 7

Views: 13969

Answers (3)

Owais Ali
Owais Ali

Reputation: 1034

:before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(
    180deg, 
    rgba(0,0,0,0.2) 0%,
    rgba(0,0,0,0.6) 100%
    ),
    linear-gradient(180deg, rgba(0,0,0,0.2) 0%, transparent 100%);
    z-index: 2;
}

Upvotes: 0

sinmrinal
sinmrinal

Reputation: 310

Simply add this-

video {
   filter: brightness(50%);
}

Upvotes: 21

Terry
Terry

Reputation: 66103

Simply use an absolutely-positioned pseudo element that is placed over the video, but underneath your text:

.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);
}

Upvotes: 5

Related Questions