jQuery实现*正反面翻牌效果
发布时间 - 2026-01-11 00:06:48 点击率:次效果图:
代码如下:
<!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
相关栏目:
【
网站优化151355 】
【
网络推广146373 】
【
网络技术251813 】
【
AI营销90571 】
相关推荐:
ChatGPT怎么生成Excel公式_ChatGPT公式生成方法【指南】
Laravel Blade模板引擎语法_Laravel Blade布局继承用法
Laravel怎么在Controller之外的地方验证数据
如何利用DOS批处理实现定时关机操作详解
Win11怎么关闭透明效果_Windows11辅助功能视觉效果设置
Laravel如何使用Gate和Policy进行授权?(权限控制)
如何快速建站并高效导出源代码?
安克发布新款氮化镓充电宝:体积缩小 30%,支持 200W 输出
标题:Vue + Vuex + JWT 身份认证的正确实践与常见误区解析
怎样使用JSON进行数据交换_它有什么限制
齐河建站公司:营销型网站建设与SEO优化双核驱动策略
如何在Windows环境下新建FTP站点并设置权限?
百度浏览器网页无法复制文字怎么办 百度浏览器复制修复
如何用AI一键生成爆款短视频文案?小红书AI文案写作指令【教程】
如何使用 jQuery 正确渲染 Instagram 风格的标签列表
三星、SK海力士获美批准:可向中国出口芯片制造设备
Laravel API资源(Resource)怎么用_格式化Laravel API响应的最佳实践
什么是javascript作用域_全局和局部作用域有什么区别?
小视频制作网站有哪些,有什么看国内小视频的网站,求推荐?
laravel怎么在请求结束后执行任务(Terminable Middleware)_laravel Terminable Middleware请求结束任务执行方法
大同网页,大同瑞慈医院官网?
LinuxCD持续部署教程_自动发布与回滚机制
Laravel软删除怎么实现_Laravel Eloquent SoftDeletes功能使用教程
Laravel怎么实现模型属性转换Casting_Laravel自动将JSON字段转为数组【技巧】
JavaScript如何实现错误处理_try...catch如何捕获异常?
软银砸40亿美元收购DigitalBridge 强化AI资料中心布局
Laravel如何理解并使用服务容器(Service Container)_Laravel依赖注入与容器绑定说明
laravel怎么通过契约(Contracts)编程_laravel契约(Contracts)编程方法
Laravel怎么实现搜索高亮功能_Laravel结合Scout与Algolia全文检索【实战】
Laravel如何实现API速率限制?(Rate Limiting教程)
焦点电影公司作品,电影焦点结局是什么?
Laravel Eloquent关联是什么_Laravel模型一对一与一对多关系精讲
php8.4header发送头信息失败怎么办_php8.4header函数问题解决【解答】
Android使用GridView实现日历的简单功能
如何快速上传建站程序避免常见错误?
jimdo怎样用html5做选项卡_jimdo选项卡html5实现与切换效果【指南】
Laravel怎么做缓存_Laravel Cache系统提升应用速度的策略与技巧
微信小程序 配置文件详细介绍
Laravel怎么创建控制器Controller_Laravel路由绑定与控制器逻辑编写【指南】
如何快速搭建二级域名独立网站?
Laravel如何使用Seeder填充数据_Laravel模型工厂Factory批量生成测试数据【方法】
如何快速搭建自助建站会员专属系统?
香港服务器网站生成指南:免费资源整合与高速稳定配置方案
如何在HTML表单中获取用户输入并用JavaScript动态控制复利计算循环
javascript中的try catch异常捕获机制用法分析
php在windows下怎么调试_phpwindows环境调试操作说明【操作】
uc浏览器二维码扫描入口_uc浏览器扫码功能使用地址
Win11怎么查看显卡温度 Win11任务管理器查看GPU温度【技巧】
极客网站有哪些,DoNews、36氪、爱范儿、虎嗅、雷锋网、极客公园这些互联网媒体网站有什么差异?
网站优化排名时,需要考虑哪些问题呢?

