html - 在叠加层上使文本变白
问题描述
在我的项目中,我有一个 div 作为背景图像。在其中,我有另一个 div 用作背景图像上的黑色叠加层。我想在我的页面上插入文本。我将此文本颜色设置为白色,但是在查看它时,叠加层使文本看起来是灰色而不是白色。
有谁知道如何使这个文本看起来完全是白色的?
这是我的代码:
.bgDiv {
width: 100%;
height: 88vh;
position: relative;
background: url("https://image.pposili/djdd.com") no-repeat center center/cover;
}
.overlay {
position: absolute;
background-color: black;
height: 100%;
width: 100%;
opacity: 0.4;
}
<div class="bgDiv">
<div class="overlay">
</div>
//THE TEXT <span style=" font-weight: 400; font-size: 25px; margin-left: 200px; color: #ffffff;">TEST </span>
</div>
解决方案
“覆盖”类在您的文本上方。因此,您的文本位于叠加层下方。你可以通过给你的文本一个更高的z-index
ie来解决这个问题z-index: 1;
推荐阅读
- r - 如何在r中重命名多个文件
- spring-boot - 如何通过单击视图名称链接到控制器中的视图文件
- angular - 以角度与 FormControlName 绑定
- python-3.x - 如何使用 pip3 在 debian 上安装 caffe?
- flutter - 是否可以从具有填充的列中排除 1 个小部件?
- hive - 如何快速制作从 hbase 到 hive 的快照?
- c# - ASP.NET Core 中配置对象的模型验证
- html - 手机导航栏不出现
- nginx - 为什么在 nginx 上运行的应用程序发出的请求不会命中 Kubernetes 服务
- caching - 使用 puppeteer 截取本地文件,但它仍在发出 web 请求?