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

 时间:2026-02-12 04:29:25

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图片顺时针(逆时针)旋转

  • 用七巧板怎样拼一个跪在地上身体后倾的人?
  • 怎样用七巧板拼一个做举手跳跃动作示范的人
  • 妈妈把我的泡面藏起来了3第24关怎么过?
  • 用七巧板智力拼图怎么拼一个跪拜的人?
  • 怪味花生的做法
  • 热门搜索
    厦门旅游景点 山西旅游 旅游学院 荔波旅游攻略 长白山旅游 大连旅游必去景点 世界旅游日 成都周边旅游 秦皇岛旅游 长岛旅游