CSS3 提供了多种变形效果,比如矩阵变形、位移、缩放、旋转和倾斜等等,让页面更加生动活泼有趣,不再一动不动。然后 IE10 以下版本的浏览器不支持 CSS3 变形,虽然 IE 有私有属性滤镜(filter),但不全面,而且效果和性能都不好。

今天介绍一款 jQuery 插件——jqueryrotate,它可以实现旋转效果。jqueryrotate 支持所有主流浏览器,包括 IE6。如果你想在低版本的 IE 中实现旋转效果,那么 jqueryrotate 是一个很好的选择。
兼容性

jqueryrotate 支持所有主流浏览器,包括 IE6。jqueryrotate 在高级浏览器中使用 CSS3 transform 属性实现,在低版本 IE 中使用 VML 实现。当然,你可以使用 IE 条件注释,低版本 IE 使用 jqueryrotate,高级浏览器则直接使用 CSS3。

参数

参数 类型 说明 默认值
angle 数字 旋转一个角度 0
animateTo 数字 从当前的角度旋转到多少度 0
step 函数 每个动画步骤中执行的回调函数,当前角度值作为该函数的第一个参数
easing 函数 自定义旋转速度、旋转效果,需要使用 jQuery.easing.js
callback 函数 旋转完成后的回调函数
getRotateAngle 函数 返回旋转对象当前的角度
stopRotate 函数 停止旋转

演示虽然使用的是图片,但 jqueryrotate 并不只是能运用在图片上,其他元素如 div 等也可以使用。同时,你可以发挥想象,制作出更多关于旋转的特效。

代码

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery旋转插件jqueryrotate</title>
<style>
/*
* ease-in-out 规定以慢速开始和结束的过渡效果
*/
img{
-moz-transition: all 0.2s ease-in-out;
-webkit-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
img:hover{
-moz-transform: rotate(70deg);
-webkit-transform: rotate(70deg);
-o-transform: rotate(70deg);
-ms-transform: rotate(70deg);
transform: rotate(70deg);
}
body{background: url(images/bg.jpg) repeat center center;}
.test {
width: 500px;
height: 300px;
margin: 30px auto;
position: relative; } .test img {
position: absolute;
top: 40%;
left: 0%;
margin-left: -70px;
margin-top: -100px;
} .test img:nth-child(1){
z-index: 1;
opacity: .6;
} .test img:nth-child(2){
z-index: 2;
transform: rotate(45deg);
} </style> <script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.rotate.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//旋转45度
$('#img1').rotate({angle:45}); //鼠标滑过旋转180,离开回0度
$("#img2").rotate({
bind:
{
mouseover : function() {
$(this).rotate({animateTo:180});
},
mouseout : function() {
$(this).rotate({animateTo:0});
}
}
}); //慢速旋转
var angle = 0;
setInterval(function(){
angle+=3;
$("#img3").rotate(angle);
},50); //快速旋转一周,callback回调有时间间隔
var rotation = function (){
$("#img4").rotate({
angle:0,
animateTo:360,
callback: rotation
});
}
rotation(); //这个没搞明白怎么用
var rotation2 = function (){
$("#img5").rotate({
angle:0,
animateTo:360,
callback: rotation2,
easing: function (x,t,b,c,d){ // t: current time, b: begInnIng value, c: change In value, d: duration
return c*(t/d)+b;
}
});
}
rotation2(); //点击后旋转180度
$("#img6").rotate({
bind:
{
click: function(){
$(this).rotate({ angle:0,animateTo:180,easing: $.easing.easeInOutExpo })
}
}
}); //每次点击在原基础上旋转90度
var value2 = 0
$("#img7").rotate({
bind:
{
click: function(){
value2 +=90;
$(this).rotate({ animateTo:value2})
}
}
}); //跷跷板动画
var nnn = 0;
setInterval(function(){
nnn++;
if(nnn>=20){
$("#img8").rotate(45);
}
if(nnn>=50){
$("#img8").rotate(0);
nnn=0;
}
},50); });
</script> </head> <body>
<img id="img1" src="data:images/chrome.png" width="256" height="256"/>
<img id="img2" src="data:images/chrome.png" width="256" height="256" />
<img id="img3" src="data:images/chrome.png" width="256" height="256"/>
<img id="img4" src="data:images/chrome.png" width="256" height="256"/>
<br>
<img id="img5" src="data:images/chrome.png" width="256" height="256"/>
<img id="img6" src="data:images/chrome.png" width="256" height="256"/>
<img id="img7" src="data:images/chrome.png" width="256" height="256"/>
<img id="img8" src="data:images/chrome.png" width="256" height="256"/>
<br>鼠标滑过后旋转,离开后恢复原位:
<div class="test">
<img src="data:images/cardKingClub.png" alt="" width="70" height="100" />
<a herf="#"><img src="data:images/cardKingClub.png" alt="" width="70" height="100" /></a>
</div>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
html5网页动画总结--jQuery旋转插件jqueryrotate </div> </body>
</html>

html5网页动画总结--jQuery旋转插件jqueryrotate的更多相关文章

  1. jQuery旋转插件jqueryrotate 图片旋转

    "jquery.rotate.min.js"是jQuery旋转rotate插件,支持Internet Explorer 6.0+ .Firefox 2.0 .Safari 3 .O ...

  2. jQuery旋转插件—rotate-摘自网友

    jQuery旋转插件—rotate 时间:2013年01月03日作者:愚人码头查看次数:5,660 views评论次数:6条评论 网上发现一个很有意思的jQuery旋转插件,支持Internet Ex ...

  3. jQuery旋转插件

    jQuery旋转插件,支持Internet Explorer 6.0 + .Firefox 2.0.Safari 3.Opera 9.Google Chrome,高级浏览器下使用Transform,低 ...

  4. jQuery抽奖插件 jQueryRotate

    实现代码 网页中引用 <script type="text/javascript" src="js/jquery.min.js"></scri ...

  5. jQuery旋转插件—rotate

    jQuery旋转插件,支持Internet Explorer 6.0+ .Firefox 2.0 .Safari 3 .Opera 9 .Google Chrome rotate(angle) 正值表 ...

  6. 基于HTML5 audio元素播放声音jQuery小插件

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=1609 一.前面的些唠 ...

  7. The jQuery HTML5 Audio / Video Library (jQuery jPlayer插件给你的站点增加视频和音频功能)

    http://jplayer.org/ The jQuery HTML5 Audio / Video Library jPlayer is the completely free and open s ...

  8. jQuery旋转插件jquery.rotate.js 让图片旋转

    演示1 直接旋转一个角度 $('#img1').rotate(45); 演示2 鼠标移动效果 $('#img2').rotate({ bind : { mouseover : function(){ ...

  9. jquery旋转插件rotate参数说明

    具体可见:http://www.jianshu.com/p/b632a1ed6a57

随机推荐

  1. mac os安装基本的install环境,命令行安装软件

    以下摘自:homebrew官网. 在 OS X 中找不到您想要的软件?Homebrew 给你所需. 首先需要安装一个很多人都在用的包:homebrew 安装 Homebrew 开 Terminal, ...

  2. [C++] C\C++ printf 输出格式

    1.转换说明符      %a(%A)     浮点数.十六进制数字和p-(P-)记数法(C99)      %c         字符      %d         有符号十进制整数      % ...

  3. 喜迎2015年新年:坦克大战(Robocode)游戏编程比赛图文总结

    2015春节前,葡萄城的软件工程师以特有的方式来迎接新年——2015新年编程邀请赛. 邀请赛的初衷,是和大家一起,寻找编程最初的单纯的快乐.       在代码的世界里,添加动力,继续远航.      ...

  4. Lingo 做线性规划 - DEA

    Reference: <An Introduction to Management Science Quantitative Approaches to Decision Making, Rev ...

  5. atitit.GMT UTC Catitit.GMT UTC CST DST CET 星期 月份 节日 时间的不同本质and起源

    atitit.GMT UTC Catitit.GMT UTC CST DST CET 星期 月份 节日 时间的不同本质and起源 1. GMT(Greenwich Mean Time)是格林尼治平时 ...

  6. 关于EditText的OnClickListener失效的解决办法

    最近开发,遇到一个问题,就是如果EditText只作为显示,不需要编辑文本,但需要点击该布局可以执行其他事件,就会冲突,EditText依然处于文本编辑状态: 如: 如:有5个EditText,最后一 ...

  7. Delphi 如何让程序获取权限结束指定进程?

    比如说让程序结束进程中360sd.exe 获取权限,否则会拒绝访问, 要怎么写?   补充: 这段代码中……点击按钮后结束不了360进程! unit Unit1;interfaceusesWindow ...

  8. web应用程序 ---- 日志系统的设计

    最近在做一个小的项目,是web的应用程序,最近也有点时间,把日志管理来简单的说说. 日志,就是需要记录一些自己感兴趣的信息,把它保存起来,具体保存在哪里?保存多长时间?这些要求都是根据不同的项目需求而 ...

  9. 关于年终奖励的扣税算法BUG

    这么多年,第一次拿年终奖,于是查一下年终奖是怎么扣税的,根据 国税发[2005]9号 适用公式为: 应纳税额=雇员当月取得全年一次性奖金×适用税率一速算扣除数 年终奖: /= 的税率是3% 按照网上说 ...

  10. 报错:ASP.NET Web API中找不到与请求匹配的HTTP资源

    当发出GET请求: GET http://localhost:54176/api/Products 报如下错: {  "message": "找不到与请求 URI“htt ...