How to apply a white “filter” (alpha 50%) on a HTML tag?
How to apply a white “filter” (alpha 50%) on a HTML <video> tag?
I am looking for a way to add a "white filter" on top of a HTML , i.e. basically I want the video to look like being being below a white layer of 50% alpha.
I checkout the css filter solution but it does not provider unicolor option, any idea?
<video
poster="/assets/img/stuff.png"
autoplay muted loop
id="background-video">
<source src="/assets/video/stuff.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
2 Answers
2
Test this one:
*
padding: 0;
margin: 0;
border: 0;
#video_container
width: 480px;
height: 270px;
position: relative;
z-index: 0;
video
position: absolute;
width: 100%;
height: 100%;
background-color: royalblue;
z-index: 0;
#overlay
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.5);
z-index: 1;
<div id="video_container">
<div id="overlay"></div>
<video
poster="/assets/img/stuff.png"
autoplay muted loop
id="background-video">
<source src="/assets/video/stuff.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video><!--about poster attibute you used: https://www.w3schools.com/tags/att_video_poster.asp-->
</div>
Thanks it also works!
– Ehouarn Perret
Sep 8 '18 at 11:27
The solution is:
<div class="overlay">
<video
poster="/assets/img/stuff.png"
autoplay muted loop
id="background-video">
<source src="/assets/video/stuff.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
</div>
With
.overlay
z-index: 2;
background: white;
opacity: 0.5;
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
please add your code or working example
– Nidhi
Sep 8 '18 at 10:06