jquery 树形框 横_jquery 横向折叠插件

jquery 横向折叠插件lateral-fold - 懒人建站http://51xuediannao.com/

body{background: #000;}

ul{margin-top:0; margin-bottom:0; padding-left:0;*margin-left:0;list-style-type: none;border: 5px solid #fff;}

a{ text-decoration: none; color: #333}

/*依赖的css 其中的 height: 300px; width: 40px; background 都是随手定义的,请自定义您的样式*/

.lateral-fold{height: 460px; overflow: hidden;}

.lateral-fold li,.lateral-fold-tab{width: 102px; height: 100%; float: left; }

.lateral-fold li{ overflow: hidden; transition: all 0.5s;}

.lateral-fold-tab{background: #fff;}

.lateral-fold-con{ overflow: hidden;width: 0;}

.active {

background: red;

width: 102px;

height: 460px;

}

/*自定义*/

#test1{width: 1200px; border:#ddd solid 1px; margin: 0 auto;}

#test1 ul{ height: 460px; }

#test1 ul li{width: 102px;}

#test1 .lateral-fold-tab{}

#test1 .lateral-fold-con{}

jquery 横向折叠插件lateral-fold

懒人建站http://51xuediannao.com/

  • lateral-fold-con
  • lateral-fold-con
  • lateral-fold-con
  • lateral-fold-con
  • lateral-fold-con

//懒人建站http://51xuediannao.com/

$.extend($.fn,{

lateralFold:function(callback){

//event 事件 可以是 click 或者 mouseenter 注册在盒子的data-event="mouseenter" ,默认 click

return this.each(function(){

var $box = $(this),

$lis = $box.children("li"),

boxWidth = $box.width(),

tabWidth = $box.find(".lateral-fold-tab").eq(0).width();

var event = $box.data("event")||"click";

var liWidth = boxWidth - tabWidth * ($lis.length-1);

$box.on(event,".lateral-fold-tab",function(){

var $this = $(this),$p = $this.closest("li");

if($p.hasClass("on")){

return

}

$p.addClass("on").css("width",liWidth).siblings("li").removeClass("on").css("width",102);

typeof callback=="function" && callback.call(this,$box);

});

//初始化

$box.children(".on").css("width",liWidth);

typeof callback=="function" && callback.call(this,$box);

});

}

});

//调用测试

$(".lateral-fold").lateralFold();

运 行

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值