jquery 横向折叠插件
作者:佳明妈 来源:web前端开发 2016-11-07 人气:9829 QQ交流群:4188479jquery 横向折叠插件lateral-fold,点击横向得选项卡,产生横向折叠展开的效果,也可以当做横向切换的选项卡使用。横向折叠插件核心样式

jquery 横向折叠插件lateral-fold,点击横向得选项卡,产生横向折叠展开的效果,也可以当做横向切换的选项卡使用。
横向折叠插件核心样式
/*依赖的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{}
横向折叠插件核心js代码
//懒人建站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();
↓ 查看全文
jquery 横向折叠插件由懒人建站收集整理,您可以自由传播,请主动带上本文链接
懒人建站就是免费分享,觉得有用就多来支持一下,没有能帮到您,懒人也只能表示遗憾,希望有一天能帮到您。
jquery 横向折叠插件-最新评论