自动跳动滑动门html,jQuery 滑动门自动滑动实现代码

作者:创新互联 文章来源:前端开发部 点击数:8ff362d2e7a26fe34b8e93a30d36fb16.gif 更新时间:2008-10-08

本文要介绍的 jQuery 让滑动门滑动起来。

先看一个我精简出来的 DEMO。然后再来分解一下:

一、首先还是 HTML 部分:

代码如下 复制代码

tabContentA

tabContentB

tabContentC

  • switcherA
  • switcherB
  • switcherC

二、然后是 CSS 部分:

代码如下 复制代码

*{margin:0;padding:0;}

#tab{height:180px;padding:10px 20px;overflow:hidden;position:relative;}

#tabContentB,#tabContentC{display:none;}/* 非首块内容区域默认不显示 */

#tab div{height:200px;}

#switcher li{width:150px;height:30px;line-height:30px;text-align:center;float:left;cursor:pointer;list-style:none;}

#switcher span{width:10px;height:10px;overflow:hidden;position:absolute;background:#000;display:block;left:75px;}

三、js 部分(先加载 jQuery,这个就略过了,你懂的):

代码如下 复制代码

$(document).ready(function(){

$("li#switcherA").hover(function () {

$("#switcher span").stop(true,true);

$("#switcher span").animate({

left:"75px"

},250);

$("#tabContentA").fadeIn("slow");

$("#tabContentB").fadeOut("fast");

$("#tabContentC").fadeOut("fast")

});

$("li#switcherB").hover(function () {

$("#switcher span").stop(true,true);

$("#switcher span").animate({

left:"225px"

},250);

$("#tabContentA").fadeOut("fast");

$("#tabContentB").fadeIn("slow");

$("#tabContentC").fadeOut("fast")

});

$("li#switcherC").hover(function () {

$("#switcher span").stop(true,true);

$("#switcher span").animate({

left:"375px"

},250);

$("#tabContentA").fadeOut("fast");

$("#tabContentB").fadeOut("fast");

$("#tabContentC").fadeIn("slow")

});

});

完整实例

代码如下 复制代码

*{margin:0;padding:0;}

#tab{height:180px;padding:10px 20px;overflow:hidden;position:relative;}

#tabContentB,#tabContentC{display:none;}

#tab div{height:200px;}

#switcher li{width:150px;height:30px;line-height:30px;text-align:center;float:left;cursor:pointer;list-style:none;}

#switcher span{width:10px;height:10px;overflow:hidden;position:absolute;left:75px;background:#000;display:block;}

jQuery 让滑动门滑动起来

tabContentA

tabContentA

tabContentA

tabContentA

tabContentA

tabContentA

tabContentA

tabContentA

tabContentB

tabContentB

tabContentB

tabContentB

tabContentB

tabContentB

tabContentB

tabContentB

tabContentC

tabContentC

tabContentC

tabContentC

tabContentC

tabContentC

tabContentC

tabContentC

  • switcherA
  • switcherB
  • switcherC

$(document).ready(function(){

$("li#switcherA").hover(function () {

$("#switcher span").stop(true,true);

$("#switcher span").animate({

left:"75px"

},250);

$("#tabContentA").fadeIn("slow");

$("#tabContentB").fadeOut("fast");

$("#tabContentC").fadeOut("fast")

});

$("li#switcherB").hover(function () {

$("#switcher span").stop(true,true);

$("#switcher span").animate({

left:"225px"

},250);

$("#tabContentA").fadeOut("fast");

$("#tabContentB").fadeIn("slow");

$("#tabContentC").fadeOut("fast")

});

$("li#switcherC").hover(function () {

$("#switcher span").st

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值