我试图添加一个透明的黑色覆盖图像时,鼠标悬停在图像只有 CSS。这可能吗?我试过了:
Http://jsfiddle.net/zf5am/565/
但我没法让 Div 出现。
<div class="image">
<img src="http://www.newyorker.com/online/blogs/photobooth/NASAEarth-01.jpg" alt="" />
<div class="overlay" />
</div>
.image {
position: relative;
border: 1px solid black;
width: 200px;
height: 200px;
}
.image img {
max-width: 100%;
max-height: 100%;
}
.overlay {
position: absolute;
top: 0;
left: 0;
display: none;
background-color: red;
z-index: 200;
}
.overlay:hover {
display: block;
}