【发布时间】:2014-09-13 23:54:32
【问题描述】:
请注意,这在几周前对我有用,但它停止了工作。我不知道 Chrome 最近的更新是否破坏了此代码。
我有一个悬停动画,当您将鼠标悬停在“免费试用”上时,其余的 div 会平滑地滑入视图,当用户停止悬停时,还有另一个幻灯片效果隐藏了大部分 div。最终,我试图在悬停生效时显示一个按钮,但是当鼠标从#trial div 移开时隐藏它。
问题不在于它根本不起作用。问题是当用户第一次将其悬停时,效果不起作用/过渡持续时间不起作用。第一次悬停被跳过,然后所有悬停在该工作之后。
这是几周前的工作。 Chrome 的新更新是否会导致此问题发生?我在 Internet Explorer 中对此进行了测试,但它似乎不起作用。请使用 Chrome 测试小提琴:
HTML:
<div id="trial" style="position:fixed; right:0; top:80px; z-index:999; display:inline;vertical-align:middle;">
<h1 style="display:inline-block;vertical-align:middle; width:80px;padding-right:30px;">Free Trial!</h1>
<p style="display:inline-block; width:300px;vertical-align:middle;">Download the free trial for a
taste of what our powerful
software can do!<br><a href="google.com"><button style="padding:0.5em 0.5em;font-weight:bold;text-align:center;margin-left:75px;margin-top:10px;">DOWNLOAD</button></a>
</p>
</div>
JavaScript:
$(document).ready(function(){
$('#trial').hide();
$('#trial').delay(500).show('slide',{direction:'right'},500);
$("#trial").hover(function(){
$("#trial").css("transition","all .5s ease-in-out");
},function(){
$("#trial").css("transition","all .5s ease-in-out");
});
});
CSS:
#trial{
-webkit-transform:translateX(300px);
-ms-transform:translateX(300px);
-moz-transform:translateX(300px);
background: darkred;
padding-left:30px;
font-size:80%;
color:white;
cursor:pointer;
border-top-left-radius:5px;
border-bottom-left-radius:5px;
}
#trial:hover{
-ms-transform:translateX(0px);
-moz-transform:translateX(0px);
-webkit-transform:translateX(0px);
-ms-transition: all 400ms ease-in-out;
-moz-transition: all 400 ms ease-in-out;
-webkit-transition: all 400ms ease-in-out;
-webkit-transition-property: anything;
}
#trial button{
cursor:pointer;
-webkit-transition: all 100ms ease-in-out;
}
【问题讨论】:
-
虽然 jsfiddle 很有帮助,但您应该在问题中添加代码。
标签: jquery html css google-chrome