原生js实现手风琴功能支持横纵向调用

话不多说,请看代码

rush:xhtml;"> <Meta charset="UTF-8"> 手风琴-<a href="https://www.jb51.cc/tag/zhichi/" target="_blank" class="keywords">支持</a>横纵向<a href="https://www.jb51.cc/tag/diaoyong/" target="_blank" class="keywords">调用</a>-原生js封装 decoration: none; color:#333; } .header{ width: 960px; padding-top: 15px; margin: 0 auto; line-height: 30px; text-align: right; } .header a{ margin: 0 5px; } .main{ width:960px; margin: 50px auto 0; } .code{ border:1px dashed #e2e2e2; padding:10px 5px; margin-bottom:25px; } pre { font-family: "Microsoft Yahei",Arial,Helvetica; white-space: pre-wrap; /*css-3*/ white-space: -moz-pre-wrap; /*Mozilla,since1999*/ white-space: -pre-wrap; /*Opera4-6*/ white-space: -o-pre-wrap; /*Opera7*/ word-wrap: break-word; /*InternetExplorer5.5+*/ } .example{ padding-top:40px; margin-bottom:90px; } .example .call{ padding:18px 5px; background:#f0f5f8; } .example h2{ padding-top:20px; margin-bottom:7px; } .example table { width:100%; table-layout:fixed; border-collapse: collapse; border-spacing: 0; border: 1px solid #cee1ee; border-left: 0; } .example thead { border-bottom: 1px solid #cee1ee; background-color: #e3eef8; } .example tr { line-height: 24px; font-size: 13px; } .example tr:nth-child(2n) { background-color: #f0f5f8; } .example tr th,.example tr td { border-left: 1px solid #cee1ee; word-break: break-all; word-wrap: break-word; padding:0 10px; font-weight: normal; } .example tr th { color: #555; padding-top: 2px; padding-bottom: 2px; text-align: left; } /*公共*/ .accordion-container { height: 200px; margin: 20px auto; /*border: 1px solid #ccc;*/ border-right: 1px solid #ccc; border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; overflow: hidden; position: relative; } .accordion-list{ position: absolute; left: 0; width: 150px; border-left: 1px solid #ccc; height: 100%; /*-webkit-transition: all .1s linear; -moz-transition: all .1s linear; -o-transition: all .1s linear; -ms-transition: all .1s linear; transition: all .1s linear;*/ } /*.accordion-container li:last-child{ border:none; }*/ .accordion-container2{ width: 500px; border-top:none; } .accordion-container2 .accordion-list{ width: 100%; height: 100px; border-top: 1px solid #ccc; }
dion-container" id="accordion">
  • dion-list">1
  • dion-list">2
  • dion-list">3
  • dion-list">4
  • dion-list">5
不传参数,执行认参数,鼠标点击预览图切换

new accordion("#accordion");

dion-container" id="accordion1">
  • dion-list">1
  • dion-list">2
  • dion-list">3
  • dion-list">4
  • dion-list">5
执行认参数,设置横向展开{direction: "x"},设置隐藏体可是区大小{expose: 50}认单位为px,鼠标点击预览图切换

new accordion("#accordion1",expose: 50 });

dion-container accordion-container2" id="accordion2">
  • dion-list">1
  • dion-list">2
  • dion-list">3
  • dion-list">4
  • dion-list">5
  • dion-list">6
执行认参数,设置纵向展开{direction: "y"},设置隐藏体可是区大小{expose: 30}认单位为px,鼠标点击预览图切换

new accordion("#accordion2",expose: 30 });

dion-container accordion-container2" id="accordion3">
  • dion-list">1
  • dion-list">2
  • dion-list">3
  • dion-list">4
执行认参数,设置纵向展开{direction: "y"},设置隐藏体可是区大小{expose: 30}认单位为px,设置运动速度{speed: 100},鼠标点击预览图切换

new accordion("#accordion3",speed: 100 });

调用方法

new accordion(selector,{options});

options参数

默认值 说明 默认单位为px

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持编程之家!

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...