网页特效
建站首页
|
广告代码
|
源码下载
|
站长工具
|
字体下载
|
网页模板
|
收藏本站
|
设为首页
网站首页
菜单导航
日期时间
背景图像
图层样式
鼠标键盘
页面窗口
色彩表格
链接文字
表单按钮
计数转换
游戏娱乐
综合实例
特效
热门搜索:
特效代码
js脚本
导航菜单
热点推荐:
英文字体
人民币汇率
dw插件
站长常用软件
alexa排名查询
您的位置:
网页特效
->
背景图像
-> 仿新浪微博图片旋转效果
仿新浪微博图片旋转效果
作者:admin 发布时间:2010-8-31 20:28:21 发布人: admin
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>仿新浪微博图片旋转效果丨jz123.Cn</title> <meta http-equiv="content-type" content="text/html;charset=gb2312"> <style type="text/css"> ul{padding:0 15px;} ul li{padding-bottom:15px;border-bottom:1px dashed #EEE;} .caption{padding:15px 0 5px;} .caption input{margin-right:10px;padding:0 10px;} </style> <script type="text/javascript"> /* * www.bankcha.com * ok!: MSIE 6, 7, 8, Firefox 3.6, chrome 4, Safari 4, Opera 10 * o 旋转图片ID; * p 选择旋转方向,固定值为'left'或'right'; */ function rotate(o,p){ var img = document.getElementById(o); if(!img || !p) return false; var n = img.getAttribute('step'); if(n== null) n=0; if(p=='left'){ (n==3)? n=0:n++; }else if(p=='right'){ (n==0)? n=3:n--; } img.setAttribute('step',n); //MSIE if(document.all) { img.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation='+ n +')'; //HACK FOR MSIE 8 switch(n){ case 0: img.parentNode.style.height = img.height; break; case 1: img.parentNode.style.height = img.width; break; case 2: img.parentNode.style.height = img.height; break; case 3: img.parentNode.style.height = img.width; break; } //DOM }else{ var c = document.getElementById('canvas_'+o); if(c== null){ img.style.visibility = 'hidden'; img.style.position = 'absolute'; c = document.createElement('canvas'); c.setAttribute("id",'canvas_'+o); img.parentNode.appendChild(c); } var canvasContext = c.getContext('2d'); switch(n) { default : case 0 : c.setAttribute('width', img.width); c.setAttribute('height', img.height); canvasContext.rotate(0 * Math.PI / 180); canvasContext.drawImage(img, 0, 0); break; case 1 : c.setAttribute('width', img.height); c.setAttribute('height', img.width); canvasContext.rotate(90 * Math.PI / 180); canvasContext.drawImage(img, 0, -img.height); break; case 2 : c.setAttribute('width', img.width); c.setAttribute('height', img.height); canvasContext.rotate(180 * Math.PI / 180); canvasContext.drawImage(img, -img.width, -img.height); break; case 3 : c.setAttribute('width', img.height); c.setAttribute('height', img.width); canvasContext.rotate(270 * Math.PI / 180); canvasContext.drawImage(img, -img.width, 0); break; }; } } </script> </head> <body> 预览效果时左下角会提示错误,而且看不到效果,刷新一下就可以看到效果了;当然,在实际使用中,不会出现这样的问题。<br> <ul class="clearfix"> <li> <div class="caption"> <input type="button" value="turn left" onclick="rotate('pic_2','left')"> <input type="button" value="turn right" onclick="rotate('pic_2','right')"> </div> <div class="cont"> <img id="pic_2" src="http://web.archive.org/web/20150530184459im_/http://myjs.jz123.cn/upimg/03.jpg" alt=""> </div> </li> </ul> </body> </html>
仿新浪微博图片旋转效果
将本文收藏到QQ书签与更多好友分享
上一篇:文章:
CSS美化图片做成的导航条
下一篇:文章:
间隔时间滚动的图文小栏目
本类浏览排行 »
搜索页面中的内容
又一款综合搜索引擎代码
标题栏显示当前时间
倒影效果的电子表,显示当前时间
自动记录当前页面最新的更新日期
JS让网页每隔2秒弹出一次对话框
一款超酷的CSS列表排行榜
鼠标悬停放大的纯CSS分页效果
本站推荐文章 »
垂直三栏自适应等高布局
仿QQ消息管理器的文本内容样式
支付宝的控制台动画效果菜单
文字、图片拖曳移动
可拉伸移动的DIV层效果
很酷的图片伸缩放大功能
较好的视觉效果的网页选项卡
CSS实例:通过定义渐变边框给图片加阴影