首页 >

animate 实现滑动切换效果【实例代码】【jquery】

web前端|js教程animate 实现滑动切换效果【实例代码】【jquery】
animate,滑动切换
web前端-js教程
今天和大家分享一下用 animate 实现滑动切换效果的小例子
砍柴网源码,vscode安装要上网,ubuntu tty 方块,tomcat网页加载不全,nba 爬虫,php拖拽上传,广东seo哪家有实力,聊天网站程序代码,大型游戏综合网站模板lzw
大家都知道jQuery 提供的有一下几种方法能够实现滑动效果:
vip视频源码,vscode怎么安装uml插件,ubuntu提示boot,tomcat禁止目录访问,isbn爬虫评分,php高性能架构班,鸡泽seo网络营销优化,sodu网站源码,站长网网站模板下载lzw
1.slideDown()
2.slideUp()
3.slideToggle()
微场景源码 php,vscode怎么删除文件夹,用Ubuntu办公,tomcat自动重启语句,爬虫request图标,细说php 微盘,名风seo软件靠谱吗lzw
但是以上的滑动不太方便控制其滑动的方向,所以我们还是自己动手写一个吧。。。

其代码如下:

              Examples                  body{        width: 100%;        height: auto;      }      .content{        width: 150px;        height: 50px;        position: absolute;        top: 20px;        left: 20px;        overflow: hidden;        background-color: red;      }      .slide-box{        width: 300px;        position: relative;      }      .slide1{        width: 150px;        height: 50px;        float: left;        display: inline-block;        line-height: 50px;        text-align: center;        background-color: #BDD8CF;      }      .slide2{        width: 150px;        height: 50px;        float: right;        display: inline-block;        line-height: 50px;        text-align: center;        background-color: #C1C4C4;      }            
左边的元素 右边的元素
$(function(){ $(".content").hover(function(){ $(".slide-box").stop(true).animate({right:"150px"},'slow'); },function(){ $(".slide-box").stop(true).animate({right:"0"},'slow'); }); })
以上代码即可以实现一个完整的滑动效果。但是有一点需要注意,

如上图所示,需要加上 stop() 事件 ,防止鼠标快速移动时产生的多个事件,形成一个栈队,造成鼠标移除后依旧滑动甚至闪动的效果。


animate 实现滑动切换效果【实例代码】【jquery】
  • javascript 图片滑动切换代码_图象特效
  • javascript 图片滑动切换代码_图象特效 | javascript 图片滑动切换代码_图象特效 ...

    animate 实现滑动切换效果【实例代码】【jquery】
  • jQuery实现带幻灯的tab滑动切换风格菜单代码【jquery】
  • jQuery实现带幻灯的tab滑动切换风格菜单代码【jquery】 | jQuery实现带幻灯的tab滑动切换风格菜单代码【jquery】 ...

    animate 实现滑动切换效果【实例代码】【jquery】
  • multiSteps 基于Jquery的多步骤滑动切换插件【jquery】
  • multiSteps 基于Jquery的多步骤滑动切换插件【jquery】 | multiSteps 基于Jquery的多步骤滑动切换插件【jquery】 ...