html - 如何使用 CSS 在视频上创建黑色叠加层?
问题描述
各位程序员,你好,
所以我很难在我的标签上创建一个大约 50% 不透明度的黑色叠加层。
所以检查一下:
<div class="section s1">
<h1>"The Reaper"</h1>
<h2>Limited edition watch</h2>
<img src="assets\img\watch.png" alt="Watch">
<div class="video-container">
<video data-autoplay loop muted poster="assets\img\hero-1.jpg">
<source src="assets\img\video.webm" type="video/WebM">
</video>
</div>
</div>
和CSS:
.s1{
position: relative;
width: 100%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.s1 h1{
position: relative;
text-align: center;
color: white;
font-size: 3rem;
font-family: Georgia, 'Times New Roman', Times, serif;
z-index: 1;
left: 0px;
width: 50%;
display: inline-block;
animation: fadein 5s;
-moz-animation: fadein 5s;
/* Firefox */
-webkit-animation: fadein 5s;
/* Safari and Chrome */
-o-animation: fadein 5s;
/* Opera */
}
.s1 h2 {
position: relative;
text-align: center;
color: white;
font-size: 1rem;
font-family: Georgia, 'Times New Roman', Times, serif;
z-index: 1;
left: 0px;
width: 50%;
display: inline-block;
animation: fadein 5s;
-moz-animation: fadein 5s;
/* Firefox */
-webkit-animation: fadein 5s;
/* Safari and Chrome */
-o-animation: fadein 5s;
/* Opera */
}
.s1 img{
position: absolute;
right: 0px;
top: 0px;
height: 100%;
z-index: 1;
display: inline-block;
-webkit-animation: slide 3s forwards;
animation: slide 3s forwards;
}
.video-container{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index:0;
overflow: hidden;
}
.s1 video{
position: absolute;
top: 0;
left: 0;
object-fit: cover;
width: 100%;
height: 100%;
z-index:0;
pointer-events: none;
}
#video-container:before {
content: "";
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 2;
background: linear-gradient(to right, rgba(0, 0, 0, 0.4), rgba(17, 17, 17, 0.3));
}
所以问题是:我将如何在我的背景视频上创建黑色叠加层?随时询问有关我的问题的任何问题。
祝你有美好的一天!干杯
解决方案
我觉得你应该先用线性渐变制作背景.. 让它 background-image: lineat-gradient .....
推荐阅读
- php - .html 扩展文件中的查询字符串
- css - 使用带有外部 monorepo 包的 CSS 组合时无法解决错误
- sql - Json - 使用 SQL 按条件从数组中删除元素
- wordpress - Pantheon 托管平台上的清漆缓存问题 - WordPress 插件开发人员的问题
- nlp - nlp:这个依赖标签正确吗?在这种情况下究竟意味着什么?
- python - Pandas 对具有多个标头的数据框中的数据进行排序
- linux - x86 汇编中的击键
- java - Spark / Java 上的 MySQL 几何类型
- docker - 更改的文件未被 docker 拾取
- python - 在 Python 中打印两个列表的组合