【发布时间】:2012-09-13 02:56:14
【问题描述】:
我目前编写了带有 HTML 的 CSS 代码,这样当您将鼠标悬停在其中一个缩略图上时,一个较大的图片会在缩略图上方弹出。我目前有两个问题:
1.) 如何让缩略图上方的空白区域默认为第一张缩略图的图片
2.) 我怎样才能让图片在它们被悬停后“保持不变”,这样它们只会消失,除非另一个缩略图悬停在上面。即使鼠标进入空白区域,最后悬停的图像仍应显示。
我的网站可以在这里找到,顶部有图像显示www.ignitionspeed.com 如果不清楚,也可以在这里找到我正在寻找的一个很好的例子autoblog.com
这是我为此使用的 CSS
<style type="text/css">
.thumbnail{
z-index: 0;
}
.thumbnail:hover{
background-color: transparent;
z-index: 50;
}
.thumbnail span{ /*CSS for enlarged image*/
position: absolute;
display: block;
left: -1000px;
visibility: hidden;
color: red;
text-decoration: none;
}
.thumbnail span img{ /*CSS for enlarged image*/
border-width: 0;
padding: 2px;
}
.thumbnail:hover span{ /*CSS for enlarged image on hover*/
visibility: visible;
top: 10px;
left: 13px; /*position where enlarged image should offset horizontally */
overflow:hidden;
}
</style>
这里是 HTML
<a class="thumbnail" href="http://www.ignitionspeed.com/2012/09/lexus-lf-cc-concept.html"><img src="http://i.tinyuploads.com/25rBVR.jpg" width="117px" height="72px" border="0" /><span><img src="http://i.tinyuploads.com/25rBVR.jpg" /><br /></span></a>
<a class="thumbnail" href="http://www.ignitionspeed.com/2012/09/2009-bmw-m3-review-test-drive.html" ><img src="http://i.tinyuploads.com/IGoDa8.jpg" width="117px" height="72px" border="0" /><span><img src="http://i.tinyuploads.com/IGoDa8.jpg" /><br /></span></a>
<a class="thumbnail" href="http://www.ignitionspeed.com/2012/09/2013-audi-s6-giant-leap-in-performance.html"><img src="http://i.tinyuploads.com/aSwPv9.jpg" width="117px" height="72px" border="0" /><span><img src="http://i.tinyuploads.com/aSwPv9.jpg" /><br /></span></a>
<a class="thumbnail" href="http://www.ignitionspeed.com/2012/09/2012-lexus-lfa.html"><img src="http://i.tinyuploads.com/Gu1Pey.jpg" width="117px" height="72px" border="0" /><span><img src="http://i.tinyuploads.com/Gu1Pey.jpg" /><br /></span></a>
<a class="thumbnail" href="http://www.ignitionspeed.com/2012/08/acura-nsx-future-is-already-here.html"><img src="http://i.tinyuploads.com/VJo9IP.jpg" width="117px" height="72px" border="0" /><span><img src="http://i.tinyuploads.com/VJo9IP.jpg" /><br /></span></a>
<a class="thumbnail" href="http://www.ignitionspeed.com/2012/09/2012-jaguar-xkr-s.html"><img src="http://i.tinyuploads.com/REiZ6c.jpg" width="117px" height="72px" border="0" /><span><img src="http://i.tinyuploads.com/REiZ6c.jpg" /><br /></span></a>
非常感谢!
【问题讨论】:
-
你需要使用javascript。当缩略图失焦时,创建一个默认第一张图片的悬停事件。
-
Eric Meyer 的一些演示通过在下面创建带有纯 CSS 弹出窗口的菜单来涵盖类似的任务:meyerweb.com/eric/css/edge/popups/demo.html 和 meyerweb.com/eric/css/edge/popups/demo2.html(带有图像)。
-
如果解决方案使用 java-script/jquery,你会感到舒服吗?
标签: html css hover thumbnails blogger