請注意,這是幾個星期前我工作,但它停止工作。我不知道Chrome最近的更新是否打破了這個代碼。原始的工作CSS懸停動畫不工作 - 僅限於光線
我有一個懸停動畫,當你將鼠標懸停在「免費試用」上時,其餘的div平滑地滑入視圖中,當用戶停止懸停時,隱藏大多數div的另一個幻燈片效果。最終,我試圖在懸停生效時顯示一個按鈕,但在將鼠標從#trial
div中取出時將其隱藏。
問題不在於它根本不起作用。問題在於用戶徘徊時第一次效果沒有緩解/過渡時間不起作用。第一次懸停跳過後,所有工作後盤旋。
這是幾個星期前的工作。 Chrome的新更新是否會導致此問題發生?我在互聯網瀏覽器中測試了它,它似乎沒有工作。請使用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很有幫助,但您應該在問題中添加代碼。 – Vishwanath 2014-09-13 15:22:08
http://stackoverflow.com/questions/25760396/chrome-automatic-shift-of-web-elements可能的重複 – 2014-09-18 17:27:45