html - css 颜色叠加在每个图像悬停上

标签 html css

我正在尝试用 css 将每个图像叠加到红色背景颜色,但到目前为止我还没有成功,所有封闭的图像都叠加了。

有什么想法吗?

.gallery-overlay {
    background: rgba(200,30,30,0.5);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: none;
}
.gallery-images:hover .gallery-overlay {
    display: block;
}
<div class="box-recent-gallery">
	<div class="gallery-images">
		<img src="http://placehold.it/100x100">
		<div class="gallery-overlay"></div>
	</div>
	<div class="gallery-images">
		<img src="http://placehold.it/100x100">
		<div class="gallery-overlay"></div>
	</div>
	<div class="gallery-images">
		<img src="http://placehold.it/100x100">
		<div class="gallery-overlay"></div>
	</div>
</div>

最佳答案

.gallery-overlay {
    background: rgba(200,30,30,0.5);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: none;
}
.gallery-images {
  width: 100px;
  height: 100px;
  position:relative;
  float: left;
  margin: 0px 15px;
}
.gallery-images:hover .gallery-overlay {
    display: block;
}
<div class="box-recent-gallery">
	<div class="gallery-images">
		<img src="http://placehold.it/100x100">
		<div class="gallery-overlay"></div>
	</div>
	<div class="gallery-images">
		<img src="http://placehold.it/100x100">
		<div class="gallery-overlay"></div>
	</div>
	<div class="gallery-images">
		<img src="http://placehold.it/100x100">
		<div class="gallery-overlay"></div>
	</div>
</div>

关于html - css 颜色叠加在每个图像悬停上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39363994/

相关文章:

html - 我想让标记区域响应

javascript - 隐藏和显示div文件(已登录)

html - 将标题与图像对齐

javascript - jQuery 可放置和可拖动元素看不到对方

html - 使div在固定侧边栏(css)内可滚动

css - DIV 内容溢出到页脚,使页脚在页面上向上移动

html - 在 ngRepeat 和 Foundation 框架中使用 ngClass

javascript - 在 IE 8 中单击标签时触发单击输入

jQuery 幻灯片代码不起作用

html - <div> 内链接的自定义样式不起作用