如何解决我想在图像 css 上叠加
我想在图片顶部出现不可点击的叠加
评论区的codepen链接
html:
<img src="https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg" />
CSS:
img{
width:100px;
height:100px;
cursor: not-allowed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0,0.5);
z-index: 1000;
}
图像顶部带有灰色不透明度
解决方法
<div class="container">
<img src="https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg" />
<div class="overlay"></div>
</div>
和 css 要
img {
width: 100px;
height: 100px;
}
.container {
width: 100px;
height: 100px;
position: relative;
pointer-events: none;
}
.overlay {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: rgba( 0,0.5 );
}
,
您可以在标签后添加另一个 div。并给它的css如下
img{
width:100px;
height:100px;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0,0.5);
}
div{
position:absolute;
width:50px;
height:30px;
cursor: not-allowed;
top: 80px;
left: 10px;
right: 0;
bottom: 0;
background-color: grey;
z-index: 1000;
opacity: 0.5;
}
<img src="https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg" />
<div></div>
此外,您可以相应地调整覆盖层不可点击div的不透明度和大小
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。