简体   繁体   English

CSS悬停效果(鼠标悬停时长)

[英]CSS Hover Effects with duration of mouse out

I have the following CSS effect in below codepen. 我在以下Codepen中具有以下CSS效果。 The hover works fine, on hover the image grows and when you mouse off it gradually decreases back to original size. 悬停效果很好,悬停时图像会增长,当您将鼠标移开时,图像会逐渐减小到原始大小。 I want to change the gradual decrease so that it is quicker, infact instant. 我想更改逐渐减少的幅度,以便更快,更实际。 So basically when I move mouse away, it immediately returns to original size.. can someone help? 因此,基本上,当我将鼠标移开时,它会立即恢复为原始大小。有人可以帮忙吗?

HTML: HTML:

<div class="photo">
<img src="http://s.cdpn.io/37045/wedding-1.jpg" alt="" class="photo-image" /></div>
<div class="photo"><img src="http://s.cdpn.io/37045/wedding-2.jpg" alt="" class="photo-image" />
</div>

CSS: CSS:

.photo-image {
 cursor: pointer;
 position:relative;
 top:9px;
 left:9px;
 width:80px;
 border:1px solid #999; 
 z-index:1000;
 opacity:0.6;
 transition: width 1s, top 1s, left 1s, opacity 1s, z-index .01s;
}

.photo-image:hover{
 width:200px;
 top:-50px;
 left:-50px;
 z-index:1001;
 opacity:1;
}

Codepen example: http://codepen.io/DouglasGlover/pen/zHBid/ Codepen示例: http ://codepen.io/DouglasGlover/pen/zHBid/

Simple! 简单! Just move the transition effect from .photo-image to . 只需将过渡效果从.photo-image移到即可。 photo-image:hover : photo-image:hover

.photo-image:hover {
 transition: width 1s, top 1s, left 1s, opacity 1s, z-index .01s;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM