全网整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:400-708-3566

jQuery实现*正反面翻牌效果

效果图:

代码如下:

<!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>

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!


# jquery  # 翻牌  # jQuery flip插件实现的翻牌效果示例【附demo源码下载】  # jQuery实现个性翻牌效果导航菜单的方法  # jQuery 翻牌或百叶窗效果(内容三秒自动切换)  # 移出  # 鼠标  # 可选  # width  # height  # font  # list  # padding  # body  # size  # fff  # color  # display  # ccc  # background  # front  # relative  # position  # top  # left 


相关文章: 如何选择高效便捷的WAP商城建站系统?  制作网站建设的公司有哪些,网站建设比较好的公司都有哪些?  盘锦网站制作公司,盘锦大洼有多少5G网站?  Java解压缩zip - 解压缩多个文件或文件夹实例  如何在Mac上搭建Golang开发环境_使用Homebrew安装和管理Go版本  学生网站制作软件,一个12岁的学生写小说,应该去什么样的网站?  如何通过虚拟机搭建网站?详细步骤解析  建站主机选虚拟主机还是云服务器更好?  建站之星后台管理系统如何操作?  建站之星如何实现PC+手机+微信网站五合一建站?  昆明高端网站制作公司,昆明公租房申请网上登录入口?  javascript中对象的定义、使用以及对象和原型链操作小结  如何选择香港主机高效搭建外贸独立站?  小程序网站制作需要准备什么资料,如何制作小程序?  岳西云建站教程与模板下载_一站式快速建站系统操作指南  网站建设制作需要多少钱费用,自己做一个网站要多少钱,模板一般多少钱?  金*站制作公司有哪些,金华教育集团官网?  小说建站VPS选用指南:性能对比、配置优化与建站方案解析  如何通过VPS建站无需域名直接访问?  如何通过云梦建站系统实现SEO快速优化?  制作国外网站的软件,国外有哪些比较优质的网站推荐?  如何选择高效响应式自助建站源码系统?  微网站制作教程,我微信里的网站怎么才能复制到浏览器里?  建站上市公司网站建设方案与SEO优化服务定制指南  成都响应式网站开发,dw怎么把手机适应页面变成网页?  如何访问已购建站主机并解决登录问题?  大连网站制作公司哪家好一点,大连买房网站哪个好?  c# 服务器GC和工作站GC的区别和设置  建站之星如何保障用户数据免受黑客入侵?  建站之星代理费用多少?最新价格详情介绍  再谈Python中的字符串与字符编码(推荐)  如何在Windows环境下新建FTP站点并设置权限?  建站主机选购指南:核心配置与性价比推荐解析  如何在Golang中使用replace替换模块_指定本地或远程路径  建站之星与建站宝盒如何选择最佳方案?  logo在线制作免费网站在线制作好吗,DW网页制作时,如何在网页标题前加上logo?  新网站制作渠道有哪些,跪求一个无线渠道比较强的小说网站,我要发表小说?  建站之星如何快速解决建站难题?  免费制作统计图的网站有哪些,如何看待现如今年轻人买房难的情况?  为什么Go需要go mod文件_Go go mod文件作用说明  c++ stringstream用法详解_c++字符串与数字转换利器  建站之星如何实现网站加密操作?  jQuery 常见小例汇总  如何用免费手机建站系统零基础打造专业网站?  高端建站三要素:定制模板、企业官网与响应式设计优化  如何正确下载安装西数主机建站助手?  简历在线制作网站免费版,如何创建个人简历?  如何挑选高效建站主机与优质域名?  b2c电商网站制作流程,b2c水平综合的电商平台?  定制建站模板如何实现SEO优化与智能系统配置?18字教程 

您的项目需求

*请认真填写需求信息,我们会在24小时内与您取得联系。