在我的摄影作品集上,我设置了缩略图,因此当您将鼠标悬停在缩略图(实际上是背景图像设置为缩略图的 div)上时,通过 CSS 设置放大镜图标(这是一个绝对定位的 img)不透明度:1.0。
但是,对于某些图像,我将提供可供下载的壁纸(左上角的第一张图像是示例)。为了表明这一点,我将在这个 div 内(在对角)也有一个监视器图标(也是绝对定位的)。当此图像悬停时,我不希望出现放大镜图标。
编辑:
这是由 PHP 生成的实际 HTML:
<div class="thumbnail" style="width:240px; height:160px;">
<a href="gallery/01_CONSTRUCTS/Steam.jpg" class="shadowbox[CONSTRUCTS]" title="Steam">
<span class="rounded_corners thumb_back" style=" background-image:url('gallery/01_CONSTRUCTS/thumbs/Steam_thumb.jpg');"> </span>
<span class="rounded_corners hover_dim"> </span>
<img class="zoom" src="images/zoom.png" alt="Zoom" />
</a>
<img class="thumb_new" src="images/new.png" alt="New" />
<a class="wall_hover" href="gallery/01_CONSTRUCTS/wallpaper/Steam.jpg">
<img class="wallpaper" src="images/monitor.png" alt="DownloadWallpaper" />
</a>
</div>
以及相关的 CSS:
.thumbnail {
display: block;
position: relative;
float: left;
}
.thumbnail:hover, .thumbnail:hover .zoom {
opacity: 1.0;
-webkit-opacity: 1.0;
-moz-opacity: 1.0;
}
.thumbnail a.wall_hover + a .zoom {
display: none;
}
.thumb_new {
position: absolute;
top: 2px;
left: 2px;
z-index: 100;
}
.zoom {
position: absolute;
bottom: 3px;
right: 3px;
opacity: 0;
-webkit-opacity: 0;
-moz-opacity: 0;
transition: opacity .25s ease-in;
-webkit-transition: opacity .25s ease-in;
-moz-transition: opacity .25s ease-in;
}
.hover_dim {
background-color: rgba(0,0,0,0.5);
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
transition: background-color .25s ease-in;
-webkit-transition: background-color .25s ease-in;
-moz-transition: background-color .25s ease-in;
}
.thumbnail:hover .hover_dim {
background-color: rgba(0,0,0,0);
}
.wallpaper {
position: absolute;
bottom: 3px;
left: 3px;
}
.rounded_corners {
padding: 0;
margin: 0 5px 5px 0;
border: 0;
border-radius: 6px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
}