4.9Bootstrap学习js插件篇之折叠
来源:互联网 发布:php array split 编辑:程序博客网 时间:2024/04/29 01:33
关于
对为支持折叠功能的组件,例如accordions和导航,赋予基本样式和灵活的支持。
插件依赖
折叠插件依赖过渡效果插件。
案例
使用折叠插件,通过扩展panel组件从而构建了一个简单的accordion组件。
Collapsible Group Item #1
Collapsible Group Item #2
Collapsible Group Item #3
<div class="panel-group" id="accordion"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-toggle="collapse" data-parent="#accordion" href="#collapseOne"> Collapsible Group Item #1 </a> </h4> </div> <div id="collapseOne" class="panel-collapse collapse in"> <div class="panel-body"> Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo"> Collapsible Group Item #2 </a> </h4> </div> <div id="collapseTwo" class="panel-collapse collapse"> <div class="panel-body"> Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-toggle="collapse" data-parent="#accordion" href="#collapseThree"> Collapsible Group Item #3 </a> </h4> </div> <div id="collapseThree" class="panel-collapse collapse"> <div class="panel-body"> Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. </div> </div> </div></div>
You can also use the plugin without the accordion markup. Make a button toggle the expanding and collapsing of another element.
<button type="button" class="btn btn-danger" data-toggle="collapse" data-target="#demo"> simple collapsible</button><div id="demo" class="collapse in">...</div>
预览效果:
用法
The collapse plugin utilizes a few classes to handle the heavy lifting:
.collapse
hides the content.collapse.in
shows the content.collapsing
is added when the transition starts, and removed when it finishes
These classes can be found in component-animations.less
.
通过data属性
仅仅通过向页面元素添加data-toggle="collapse"
和data-target
就可以为其赋予控制可折叠页面元素的能力。data-target
属性接受一个CSS选择器作为其控制对象。请确保为可折叠页面元素添加collapse
class。如果你希望可折叠页面元素的默认状态是展开的,请添加in
class。
为了给一组可折叠页面元素添加控制器,添加data-parent="#selector"
即可。请参考下面给出的案例。
通过JavaScript
手动触发:
$('.collapse').collapse()
代码:
<button type="button" class="btn btn-danger" onClick="Open()">打开</button><button type="button" class="btn btn-danger" onClick="Hide()">折叠</button><div id="demo1" class="collapse in">Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunc</div>
预览:
选项
可以将选项通过data属性或JavaScript传递。对于data属性,需要将选项名称放到data-
之后,例如data-parent=""
。
accordion-group
class)togglebooleantrueToggles the collapsible element on invocation方法
.collapse(options)
赋予页面元素可折叠功能。接受一个可选的object
作为参数。
$('#myCollapsible').collapse({ toggle: false})
.collapse('toggle')
展示或隐藏一个可折叠的页面元素。
.collapse('show')
展示一个可折叠页面元素。
.collapse('hide')
隐藏一个可折叠页面元素。
事件
Bootstrap中的折叠插件对外暴露了一组可以监听的事件。
show
方法被调用之后立即触发此事件。shown.bs.collapse当可折叠页面元素显示出来之后(同时CSS过渡效果也已执行完毕),此事件被触发。hide.bs.collapse当hide
方法被调用之后,此事件被立即触发。hidden.bs.collapse当可折叠页面元素隐藏之后(同时CSS过渡效果也已执行完毕),此事件被触发。$('#myCollapsible').on('hidden.bs.collapse', function () { // do something…})
- 4.9Bootstrap学习js插件篇之折叠
- Bootstrap的js插件之折叠(collapse)
- Bootstrap学习总结笔记(22)-- 基本插件之折叠
- 4.1Bootstrap学习js插件篇之模态框
- 4.3Bootstrap学习js插件篇之标签页
- 4.4Bootstrap学习js插件篇之滚动监听
- Bootstrap学习js插件篇之提示框
- 4.5Bootstrap学习js插件篇之工具提示
- 4.6Bootstrap学习js插件篇之弹出框
- 4.7Bootstrap学习js插件篇之警告框
- 4.8Bootstrap学习js插件篇之按钮
- Bootstrap学习js插件篇之轮播
- 4.5Bootstrap学习js插件篇之工具提示
- 【BootStrap】--折叠插件
- js插件之bootstrap
- Bootstrap JS插件使用实例(6)-折叠(手风琴效果)
- Bootstrap折叠效果学习
- Bootstrap(Js插件篇)
- mysql函数应用实例:截取身份证中的生日
- 关于android通知栏图标自定义问题
- 重建eclipse的问题
- 数据生成器
- 在Ubuntu 12.04上 Hadoop源代码重新编译
- 4.9Bootstrap学习js插件篇之折叠
- 升级后,常常遇到的遇到的警告、错误,解决方法
- 转:关于const指针的问题
- IOS , plist 配置项说明
- Parentheses Balance uva
- redis.conf配置项说明
- [LeetCode] Valid Parentheses
- 1Z0-051 QUESTION 13 Q字符的特殊使用
- 链表逆序