jQuery图片顺时针(逆时针)旋转

2025-09-24 15:43:16

1、准备好需要用到的图标。

jQuery图片顺时针(逆时针)旋转

2、新建html文档。

jQuery图片顺时针(逆时针)旋转

3、书写hmtl代码。

<div class="aaaa">

<p>

    <a id="rotLeft" class="left" href="javascript:void(0);">&lt;&lt;向左转</a>

        <a id="rotRight" class="right" href="javascript:void(0);">向右转&gt;&gt;</a>

    </p>

<div id="imgBox" class="image_box">

<img id="rotImg" src="images/aaaa.jpg" />

</div>

</div>

jQuery图片顺时针(逆时针)旋转

4、书写css代码。

<style>

*{ margin:0; padding:0; list-style:none;}

.aaaa{width:500px; margin:0 auto; font-size:12px; overflow:hidden}

.aaaa p{ overflow:hidden;}

.aaaa p a{ margin:5px 0; display:inline-block; color:#333; text-decoration:none; margin-right:10px;}

.aaaa .left{ float:left;}

.aaaa .right{ float:right;}

.aaaa .image_box{text-align:center;}

</style>

jQuery图片顺时针(逆时针)旋转

5、书写并添加js代码。

<script src="js/jquery-1.2.6.pack.js"></script>

<script src="js/jquery.rotate.js"></script>

<script>

$(function(){

var rot = 0;

$("#rotRight").click(function(){

if(rot === 360){

rot = 0;

}

rot += 90;

$("#rotImg").rotate(90);

});

$("#rotLeft").click(function(){

if(rot === -360){

rot = 0;

}

rot -= 90;

$("#rotImg").rotate(-90);

});   

});

</script>

jQuery图片顺时针(逆时针)旋转

6、代码整体结构。

jQuery图片顺时针(逆时针)旋转

7、查看效果。

jQuery图片顺时针(逆时针)旋转

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢