国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery實現撲克正反面翻牌效果

2019-11-19 17:11:34
字體:
來源:轉載
供稿:網友

效果圖:

代碼如下:

<!DOCTYPE><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>【JQuery插件】撲克正反面翻牌效果</title> <style> *{margin:0px;padding:0px;list-style:none;font-size: 16px;} </style> </head> <body> <style> .demo1 {margin:10px; width: 200px;height: 100px;text-align: center;position: relative;} .demo1 .front{width: 200px;height: 100px;position:absolute;left:0px;top:0px;background-color: #000;color: #fff;} .demo1 .behind{width: 200px;height: 0px;position:absolute;left:0px;top:50px;background-color: #ccc;color: #000;display: none;} </style> <h1>demo1 y軸 (css布局提示:背面默認隱藏 height為0 top是高度的一半也就是demo中間)</h1> <div class="demo1"> <div class="front">正面正面正<br/>面正面正面<br/></div> <div class="behind">背面</div> </div> <div class="demo1"> <div class="front">正面</div> <div class="behind">背面</div> </div> <style> .demo2 {margin:10px; width: 200px;height: 100px;text-align: center;position: relative;} .demo2 .front{width: 200px;z-index: 1; height: 100px;position:absolute;left:0px;top:0px;background-color: #000;color: #fff;} .demo2 .behind{width: 0;height: 100px;z-index: 0;position:absolute;left:100px;top:0;background-color: #ccc;color: #000;} </style> <h1>demo2 x軸(css布局提示:背面默認隱藏 width為0 left是寬度的一半也就是demo中間)</h1> <div class="demo2"> <div class="front">正面</div> <div class="behind">背面</div> </div> <div class="demo2"> <div class="front">正面</div> <div class="behind">背面</div> </div><script type="text/javascript" src="http://static.cnmo-img.com.cn/js/jquery144p.js"></script><script>(function($) { /* ==================================================== 【JQuery插件】撲克翻牌效果 @auther LiuMing @blog http://www.cnblogs.com/dtdxrk/ ==================================================== @front:正面元素 @behind:背面元素 @direction:方向 @dis:距離 @mouse: 'enter' 'leave' 判斷鼠標移入移出 @speed: 速度 不填默認速度80 建議不要超過100 */ var OverTurnAnimate = function(front, behind, direction, dis, mouse, speed){ /*判斷移入移出*/ var $front = (mouse == 'enter') ? front : behind, $behind = (mouse == 'enter') ? behind : front; $front.stop(); $behind.stop(); if(direction == 'x'){ $front.animate({left: dis/2,width: 0},speed, function() { $front.hide(); $behind.show().animate({left: 0,width: dis},speed); }); }else{ $front.animate({top: dis/2,height: 0},speed, function() { $front.hide(); $behind.show().animate({top: 0,height: dis},speed); }); } }; /* @demo $('.demo1').OverTurn(@direction, @speed); @direction(String)必選 'y' || 'x' 方向 @speed(Number)可選 速度 */ $.fn.OverTurn = function(direction, speed) {   /*配置參數*/  if(direction!='x' && direction!='y'){throw new Error('OverTurn arguments error');}  $.each(this, function(){  var $this = $(this),  $front = $this.find('.front'),  $behind = $this.find('.behind'),  dis = (direction=='x') ? $this.width() :$this.height(),  s = Number(speed) || 80;/*默認速度80 建議不要超過100*/  $this.mouseenter(function() {  OverTurnAnimate($front, $behind, direction, dis, 'enter', s); }).mouseleave(function() {  OverTurnAnimate($front, $behind, direction, dis, 'leave', s); });  }); };})(jQuery);/*插件引用方法y*/$('.demo1').OverTurn('y',100);/*speed不填默認速度80 建議不要超過100*//*插件引用方法x*/$('.demo2').OverTurn('x');</script></body></html>

以上就是本文的全部內容,希望本文的內容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持武林網!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武汉市| 南和县| 威信县| 富锦市| 乾安县| 搜索| 太仓市| 读书| 临朐县| 嘉义县| 汾西县| 雷波县| 怀化市| 晋州市| 鄂伦春自治旗| 昌平区| 双峰县| 措美县| 永清县| 沅陵县| 武平县| 正阳县| 安塞县| 武夷山市| 兴义市| 息烽县| 青铜峡市| 怀宁县| 日土县| 稻城县| 铁岭县| 孝义市| 禹州市| 临洮县| 泰安市| 永登县| 金昌市| 霍城县| 图木舒克市| 敦煌市| 肃南|