html - 背景设置后的部分与上一个重叠
问题描述
一个部分与另一部分重叠。有什么解决办法吗?
这是第一部分:
<div class="background">
<div class = "row">
<div class="background-curtain"></div>
<image source="picture.jpeg">
</div>
</div>
.background{
position: relative;
}
.background-curtain{
position: absolute;
width: 100%;
height: 100%;
background-image: linear-gradient(to top, black, white);opacity: 0.3;
z-index: -100;
}
这是另一个:
<section>
<div class="background-some"></div>
</section>
.background-some{
background: url(image.jpeg);
height: 60%;
width: 100%;
}
解决方案
你可以试试这个:
<section>
<div class="background">
<div class = "row">
<div class="background-curtain"></div>
<img src="picture.jpeg">
</div>
</div>
</section>
<section>
<div class="background-some"></div>
</section>
CSS:
.background{
position: relative;
overflow: hidden;
}
.background-curtain{
position: absolute;
width: 100%;
height: 100%;
background-image: linear-gradient(to top, black, white);opacity: 0.3;
z-index: -100;
}
.background-some{
background: url(background.jpeg);
height: 60%;
width: 100%;
}
推荐阅读
- web - 在 Web 上将 C 编译为 WebAssembly
- git - 如何使用 git 避免拉取请求中的文件
- python - 在 Heroku 上上传的 Internet 应用程序不显示任何图形
- c - getpwnam() 如何工作?
- javascript - 发送多个重复的 PUT 请求
- postgresql - Postgresql 使用 array_agg 和 jsonb_build_object
- spring - 当我选中“本地请求访问令牌”复选框时,邮递员到底做了什么?
- git - 在分支上工作时从 master 那里获取特定的东西
- node.js - 在连接到 Node.js 应用程序的 Docker 容器中使用 MongoDB 的副本集
- sql-server - AdventureWorks2012 下载文件时出现 mdf 错误消息