Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add color overlay to video background

Tags:

css

How do you add a color overlay to a video like this, as seen here:

enter image description here

Here is my code so far:

HTML

<div>
  <div id="outer">
    <div id="home-top-video">
      <video autoplay loop muted width="100%">
        <source src="http://view.vzaar.com/2710053.mp4" type="video/mp4" /> Your browser does not support the video tag. We suggest you upgrade your browser.
      </video>
      <div id="home-text">
        <div><img src="http://marquesslondon.herokuapp.com/images/logo.ee1689ee.png"></div>
        <h3>LIFESTYLE</h3>
      </div>
    </div>
  </div>
</div>

CSS

#outer {
  width: 100%;
  display: block;
  text-align: center;
  position: relative;
  overflow: hidden;
  min-height: 100vh;
}

#home-top-video {
  left: 0%;
  top: 0%;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}

#home-text {
  position: absolute;
  left: 50%;
  top: 50%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}

Fiddle here: https://jsfiddle.net/kggv3213/1/

like image 860
methuselah Avatar asked Feb 24 '18 10:02

methuselah


People also ask

How do I put an overlay on my background?

We can use the property to provide an overlay to the background image. We can use the background-blend-mode property after setting the background image. For example, create a div in HTML. In CSS, set the background image using the url() function and set the no-repeat and fixed values in the background property.

How do you put a background color on the background in CSS?

Based on MDN Web Docs you can set multiple background using shorthand background property or individual properties except for background-color . In your case, you can do a trick using linear-gradient like this: background-image: url('images/checked. png'), linear-gradient(to right, #6DB3F2, #6DB3F2);


2 Answers

you can try pseudo element with gradient background:

body {
 margin:0;
}
#outer {
  text-align: center;
  position: relative;
  overflow: hidden;
  min-height: 100vh;
}
#home-top-video:before {
  content:"";
  position: absolute;
  top:0;
  right:0;
  left:0;
  bottom:0;
  z-index:1;
  background:linear-gradient(to right,rgba(65, 0, 255, 0.4),rgba(255, 0, 232, 0.3));
}

#home-top-video {
  left: 0%;
  top: 0%;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}

#home-text {
  position: absolute;
  left: 50%;
  top: 50%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  color: #fff;
  z-index:1;
}
<div id="outer">
    <div id="home-top-video">
      <video autoplay loop muted width="100%">
        <source src="http://view.vzaar.com/2710053.mp4" type="video/mp4" /> Your browser does not support the video tag. We suggest you upgrade your browser.
      </video>
      <div id="home-text">
        <div><img src="http://marquesslondon.herokuapp.com/images/logo.ee1689ee.png"></div>
        <h3>LIFESTYLE</h3>
      </div>
    </div>
  </div>
like image 108
Temani Afif Avatar answered Oct 17 '22 11:10

Temani Afif


Keep it simple, just add

#home-top-video:before {
    content: '';
    position: absolute;
    height: 100%;
    width: 100%;
    background: rgba(255,0,255,0.2); //Change as per your requirement
}
like image 28
Zuber Avatar answered Oct 17 '22 12:10

Zuber