📅  最后修改于: 2020-10-27 06:24:16             🧑  作者: Mango
折叠插件可让您轻松折叠页面。无论您是用它来构建手风琴导航还是内容盒,它都允许很多内容选择。
如果要单独包含此插件功能,则将需要crash.js 。这还要求您的Bootstrap版本中包含Transition插件。另外,如《 Bootstrap插件概述》一章所述,您可以包含bootstrap.js或缩小的bootstrap.min.js 。
您可以使用折叠插件-
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred
nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo.
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt
sapiente ea proident. Ad vegan excepteur butcher vice lomo.
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt
sapiente ea proident. Ad vegan excepteur butcher vice lomo.
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt
sapiente ea proident. Ad vegan excepteur butcher vice lomo.
在示例中可以看到,我们创建了一个简单的可折叠组件,与手风琴不同,我们没有添加data-parent属性。
下表列出了折叠插件用于处理繁重任务的类-
Sr.No. | Class &Description |
---|---|
1 | .collapse
Hides the content. |
2 | .collapse.in
Shows the content. |
3 | .collapsing
Is added when the transition starts, and removed when it finishes. |
您可以通过两种方式使用崩溃插件-
要将类似手风琴的组管理添加到可折叠控件中,请添加数据属性data-parent =“ #selector” 。
$('.collapse').collapse()
下表列出了可以通过数据属性或JavaScript传递的某些选项:
Option Name | Type/Default Value | Data attribute name | Description |
---|---|---|---|
parent | selector Default − false | data-parent | If selector is false, then all collapsible elements under the specified parent will be closed (similar to traditional accordion behavior – this dependent on the accordion-group class). |
toggle | boolean Default − true | data-toggle | Toggles the collapsible element on invocation. |
这是与可折叠元素一起使用的一些有用方法的列表。
Method | Description | Example |
---|---|---|
Options − .collapse(options) | Activates your content as a collapsible element. Accepts an optional options object. |
$('#identifier').collapse({ toggle: false }) |
Toggle − .collapse(‘toggle’) | Toggles a collapsible element to shown or hidden. |
$('#identifier').collapse('toggle') |
Show − .collapse(‘show’) | Shows a collapsible element. |
$('#identifier').collapse('show') |
Hide − .collapse(‘hide’) | Hides a collapsible element. |
$('#identifier').collapse('hide') |
以下示例演示了方法的用法-
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt
sapiente ea proident. Ad vegan excepteur butcher vice lomo.
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt
sapiente ea proident. Ad vegan excepteur butcher vice lomo.
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt
sapiente ea proident. Ad vegan excepteur butcher vice lomo.
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt
sapiente ea proident. Ad vegan excepteur butcher vice lomo.
下表列出了可以与折叠功能一起使用的一些事件。
Event | Description | Example |
---|---|---|
show.bs.collapse | Fired after the show method is called. |
$('#identifier').on('show.bs.collapse', function () { // do something }) |
shown.bs.collapse | This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete). |
$('#identifier').on('shown.bs.collapse', function () { // do something }) |
hide.bs.collapse | Fired when the hide instance method has been called. |
$('#identifier').on('hide.bs.collapse', function () { // do something }) |
hidden.bs.collapse | This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete). |
$('#identifier').on('hidden.bs.collapse', function () { // do something }) |
以下示例演示了事件的用法-
Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt
sapiente ea proident. Ad vegan excepteur butcher vice lomo.