2012-09-20 97 views
4

我目前有HTML编写的CSS代码,这样当您将鼠标悬停在其中一个缩略图上时,会在拇指钉图像上方弹出一个较大的图片。我现在有两个问题:用于弹出图片和悬停的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> 

非常感谢!

+0

有一些技术演示埃里克迈耶通过创建与下面的纯CSS弹出式菜单涵盖了类似的任务:HTTP: //meyerweb.com/eric/css/edge/popups/demo.html和http://meyerweb.com/eric/css/edge/popups/demo2.html(含图片)。 – feeela

+0

如果解决方案使用java-script/jquery,您会感到安心吗? – krish

+0

你需要使用JavaScript。创建一个默认第一张图片的悬停事件,当缩略图失焦时。 –

回答

1

试试这个为pure CSS,如果你想使用jQuery使用this

1

我不这样做,如果你熟悉Javascript和jQuery。但是你必须使用Javascript来达到你想要的效果。

实现它的最简单方法是在您使用jQuery将鼠标悬停在元素上时添加一个类。

$('.thumbnail').mouseover(function() { 
    //Removing any active hover class 
    $('.thumbnail').removeClass('hover'); 
    //Add class for the thumbnail that was just hovered 
    $(this).addClass('hover'); 
}); 

然后,在你的CSS,只需修改两个你选择的:

.thumbnail:hover, .thumbnail.hover {} 
.thumbnail:hover span, .thumbnail.hover span {} 
+0

“你必须使用Javascript”我不这么认为;在纯CSS中执行时会稍微复杂一些;我想单独为你的答案提供你的答案 - 但另一方面,这是你在这里发布的一个工作解决方案... – feeela

+0

当没有缩略图悬停时,最后一个悬停的图像必须保持可见状态,我无法想象用纯CSS来做到这一点。 – nebulousGirl