我想切換通知,jQuery UI的樣遮擋效果盲喜歡動漫:jQuery UI blind effect與CSS3僅
爲了實現這一目標,我創建CSS3動畫:
.blind-top-in{
-webkit-animation-duration: 2s;
-webkit-animation-name: blindTopIn;
animation-duration: 2s;
animation-name: blindTopIn;
}
.blind-top-out{
-webkit-animation-duration: 2s;
-webkit-animation-name: blindTopOut;
animation-duration: 2s;
animation-name: blindTopOut;
}
@-webkit-keyframes blindTopIn{
from{
max-height: 0px;
height: 0 !important;
}
to{
max-height: 75px;
height: auto !important;
}
}
@-webkit-keyframes blindTopOut{
from{
max-height: 75px;
height: auto !important;
}
to{
max-height: 0px;
height: 0 !important;
}
}
@keyframes blindTopIn{
from{
max-height: 0px;
height: 0 !important;
}
to{
max-height: 75px;
height: auto !important;
}
}
@keyframes blindTopOut{
from{
max-height: 75px;
height: auto !important;
}
to{
max-height: 0px;
height: 0 !important;
}
}
而且想法是應該的從0像素寬度到自動/ 75像素和向後的盲目。 不幸的是,這是行不通的 - 它看起來像「半高通知」出現和正常高度動畫,然後如果我添加blind-top-out
類動畫的半高,然後消失沒有動畫。我究竟做錯了什麼?如果有人決定幫助我,我會非常高興 - 事先感謝您。
快報 - 工作不完全像它應該(我不知道爲什麼),但你看到的動畫動畫只的通知「半壁江山」
.blind-top-in{
-webkit-animation-duration: 2s;
-webkit-animation-name: blindTopIn;
animation-duration: 2s;
animation-name: blindTopIn;
}
.blind-top-out{
-webkit-animation-duration: 2s;
-webkit-animation-name: blindTopOut;
animation-duration: 2s;
animation-name: blindTopOut;
}
@-webkit-keyframes blindTopIn{
from{
max-height: 0px;
height: 0 !important;
}
to{
max-height: 75px;
height: 75px !important;
}
}
@-webkit-keyframes blindTopOut{
from{
max-height: 75px;
height: 75px !important;
}
to{
max-height: 0px;
height: 0 !important;
}
}
@keyframes blindTopIn{
from{
max-height: 0px;
height: 0 !important;
}
to{
max-height: 75px;
height: 75px !important;
}
}
@keyframes blindTopOut{
from{
max-height: 75px;
height: 75px !important;
}
to{
max-height: 0px;
height: 0 !important;
}
}
<html>
<head>
<title>TODO supply a title</title>
<meta charset="windows-1250">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
"use strict";
$(document).ready(function(){
$("#showBtn").click(function(){
$("#notification").addClass("blind-top-in").removeClass("blind-top-out")});
$("#hideBtn").click(function(){
$("#notification").addClass("blind-top-out").removeClass("blind-top-in");
});
});
</script>
</head>
<body class="container">
<div id="notification" class="alert alert-info">Notify user</div>
<button id="showBtn" class="btn btn-success btn-sm" style="margin-top: 50px;">Show</button>
<button id="hideBtn" class="btn btn-danger btn-sm" style="margin-top: 80px;">Hide</button>
</div>
</body>
</html>
你可以爲你的代碼小提琴? – 2014-10-19 11:23:38
您無法在高度或高度上進行動畫製作:自動。這可能是一個有用的解決方法:http://stackoverflow.com/questions/3508605/css-transition-height-0-to-height-auto – Turnip 2014-10-19 11:25:07
@KKI添加片段 – 2014-10-19 11:29:44