transform:rotate()在没有animate.css的情况下工作,但它不能与animate.css一起使用
这是代码:
HTML
<div id="fresh">FRESH</div>
CSS
#fresh{
position : absolute;
background-color : #cf2c2c;
width: 38px;
padding-left: 2px;
color: #ffffff;
border-radius: 5px;
-ms-transform: rotate(-37deg);
-webkit-transform: rotate(-37deg);
transform: rotate(-37deg);
right: 113px;
bottom: 40px;
font-size: 10px;
z-index : 9999;
}
的jQuery
$(document).ready(function(){
$('#fresh').addClass("animated tada");
});
修改
动画不在小提琴中工作但是rotate()正在工作。意味着两者不合作。
答案 0 :(得分:1)
更新1
$(document).ready(function(){
$('#fresh').addClass("animated tada");
});
&#13;
#fresh{
position : absolute;
background-color : #cf2c2c;
width: 38px;
padding-left: 2px;
color: #ffffff;
border-radius: 5px;
-ms-transform: rotate(-37deg);
-webkit-transform: rotate(-37deg);
transform: rotate(-37deg);
right: 113px;
bottom: 40px;
font-size: 10px;
z-index : 9999;
}
&#13;
<link href="https://daneden.github.io/animate.css/animate.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="fresh">FRESH</div>
&#13;
好的,我发现为什么不起作用。有必要添加正确的animate.css文件:https://daneden.github.io/animate.css/animate.min.css
立即尝试。工作正常
更新2
$(document).ready(function(){
finish =0;
AnimateRotate("-37");
function AnimateRotate(angle) {
// caching the object for performance reasons
var $elem = $('#fresh');
// we use a pseudo object for the animation
// (starts from `0` to `angle`), you can name it as you want
$({deg: 0}).animate({deg: angle}, {
duration: 500,
step: function(now) {
// in the step-callback (that is fired each step of the animation),
// you can use the `now` paramter which contains the current
// animation-position (`0` up to `angle`)
$elem.css({
transform: 'rotate(' + now + 'deg)'
});
},
complete: function() {
if(finish!=1)
$('#fresh').addClass("animated tada");
}
});
};
$('#fresh').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
$('#fresh').removeClass();
finish=1;
AnimateRotate("-37");
});
});
&#13;
#fresh{
position : absolute;
background-color : #cf2c2c;
width: 38px;
padding-left: 2px;
color: #ffffff;
border-radius: 5px;
-ms-transform: rotate(-37deg);
-webkit-transform: rotate(-37deg);
transform: rotate(-37deg);
right: 113px;
bottom: 40px;
font-size: 10px;
z-index : 9999;
}
&#13;
<link href="https://daneden.github.io/animate.css/animate.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="fresh">FRESH</div>
&#13;
答案 1 :(得分:0)
我找到了另一个解决方案,但这并不像我预期的那样。它运作良好,仍在等待好的答案。
<强> HTML 强>
CREATE TABLE IF NOT EXISTS `tblxml` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` text NOT NULL,
`destination` text NOT NULL,
`price` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
<强> CSS 强>
<div class="rotate37i">
<div id="fresh">FRESH</div>
</div>