【发布时间】:2014-11-26 17:31:58
【问题描述】:
我想知道是否有办法延迟从“覆盖”到“包含”的背景大小的悬停效果?我已经看到过渡延迟适用于背景颜色和其他属性,但不适用于背景大小。任何帮助将不胜感激。谢谢!
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");
});
【问题讨论】:
-
尝试添加以下内容,仍然无法使用背景大小。
过渡:背景大小 2s 缓入; -moz-transition:背景大小 2s 缓入; -ms-transition:背景大小 2s 缓入; -o-transition:背景大小 2s 缓入; -webkit-transition:背景大小 2s 缓入;过渡:-延迟1s; -moz 过渡延迟:1 秒; -ms-转换延迟:1; -o-过渡延迟:1s; -webkit-transition-delay:1s;
-
好的,只是记得看过它,并认为它可能会有所帮助!对不起,它没有工作!祝你好运:)
标签: css hover delay background-size