【发布时间】:2019-07-24 02:35:34
【问题描述】:
我一直在搜索如何添加黑色叠加层,例如: https://ocean19.com/wp-content/uploads/2017/04/black.jpg
但只使用 html 和 css。 我尝试了很多方法,但还是失败了。是否可以只使用 html 和 css 或者我也应该使用 javascript 和其他东西?
我当前的代码:
html:
<div class="container">
<img src="image/head1.jpg" class="center-fit">
<div class="centered">Centered</div>
</div>
css:
.container {
position: relative;
text-align: center;
color: white;
height:100%;
display: grid;
}
.center-fit {
width: 100%;
max-width: 1903px;
max-height: auto;
position: absolute;
margin-left: -8px;
background: rgba(0, 0, 0,1);
}
【问题讨论】: