javascript - 求助关于JQ动画问题。
PHP中文网
PHP中文网 2017-04-10 17:30:33
0
2
312

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="jquery.rotate.js"></script>
<script>
$(function(){

 $("#di").click(function(){
    $(this).animate({
        rotate:"95deg"  
    },function(){
    
$(this).fadeOut()
           .hide(); 
                   
  });           
});              
        
$("#di1").click(function(){
    $("#di").animate({
        rotate:"0deg"
        },function(){
        $(this).fadeIn()
               .show();
                      })//让p旋转回来但是好像这个没有效果。
                   
                   })
        });                    
                            

</script>
<style>
.box{ position:relative;

  width:900px;
  height:900px;}

di{

width: 600px;
height: 600px;
background: #000;
position: absolute;
transform:;         
left: 1px;
top: 1px;

}

di1{ width:100px;

  height:100px;
  background:#F00;  }    

</style>
</head>
<body>
<p class="box">
<p id="di">
</p>
<p id="di1">
</p>
</p>
</body>
</html>

PHP中文网
PHP中文网

认证0级讲师

membalas semua(2)
小葫芦

何必呢,用 css3 class 去设置 transform 属性吧,这样效果好点比如

.active{
    transform: rotate(95deg);
}

JS

$("#di").click(function(){
    $(this).addClass('active');
});
Ty80
#di{
  transition:all 2s liner; 
}

再加上上面那位小伙伴的代码就OK了

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan