html - 如何在不影响子文本的情况下为背景图像添加特定的不透明度?
问题描述
我尝试放置不透明度较低的背景图像,但不幸的是文本也受到不透明度的影响。我尝试使用背景 rgba 和伪元素,但没有成功。你有什么建议吗?
.news {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(4, 1fr);
background: transparent url(https://upload.wikimedia.org/wikipedia/commons/thumb/b/b5/Lion_d%27Afrique.jpg/1024px-Lion_d%27Afrique.jpg) no-repeat center center;
background-size: cover;
margin-top: 10vh;
margin-bottom: 10vh;
height: 30vh;
white-space: nowrap;
}
.subtitlesec {
font-family: 'Roboto', sans-serif;
font-size: 2rem;
font-weight: 500;
text-transform: uppercase;
color: #34b828;
grid-column: 1/4;
grid-row: 1/4;
place-self: center;
}
.discoverBox {
grid-column: 2/3;
grid-row: 3/5;
place-self: center;
}
.discover {
font-size: 1rem;
font-weight: bold;
text-transform: uppercase;
color: #ad6506;
border: 2px solid #01172e;
border-radius: 20px;
padding: 1.3vh;
background-color: white;
}
<section>
<div class="news">
<span class="subtitlesec">Nouveautés</span>
<div class="discoverBox"><button class="discover">découvrir</button></div>
</div>
</section>
解决方案
推荐阅读
- excel - Excel VBA - 使用“~”分隔值将多个文本文件导入同一个工作簿
- python - 如何在 Docker CMD 中链接 python 和 S3 命令?
- pythonanywhere - 结束后台 nohup 进程?
- scala - 如何在 Spark 中处理大参考数据
- android - 如何制作可以在全屏区域移动的浮动小部件
- powershell - IIS 回收 Powershell 部署;代码未更改设置
- python - 有没有办法在 for 中使用 os.system?
- javascript - 如何修复javascript中的“ids is not a function”错误
- python - 从键值对中的浮点值中剥离空间
- csv - 如何将 csv 文件导入 cplex