我想知道是否有办法延迟从“覆盖”到“包含”的背景大小的悬停效果?我已经看到过渡延迟适用于背景颜色和其他属性,但不适用于背景大小。任何帮助将不胜感激。谢谢!
div{
display:inline-block;
width: 100px;
height: 100px;
padding:5px;
margin:10px;
border:1px solid #ccc;
background-image: url("http://i.stack.imgur.com/2OrtT.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: 50% 50%;
transition: 0s background-size;
transition-delay:1s;
}
div:hover{
background-size: contain;
background-color:red;
}
更新 也许我应该澄清一下我想延迟悬停效果发生但不延长动画的持续时间。
与此类似... http://dabblet.com/gist/1498443
最近更新
我想出了一种通过混合使用 CSS 和 javascript 来解决这个问题的方法。
这种方式“背景大小”与“包含”和“覆盖”一起使用
$("#tmp").hover(function() {
/* Mouse enter */
var thisone = $(this);
window.mytimeout = setTimeout(function() {
thisone.addClass("mouseon");
}, 1000);
}, function() {
/* Mouse leave */
clearTimeout(window.mytimeout);
$(this).removeClass("mouseon");
});