diff options
| author | Johann-S <[email protected]> | 2017-06-14 13:21:49 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-06-14 13:21:49 +0200 |
| commit | f0124769c9850bea321cbd82d6250b756a52bb52 (patch) | |
| tree | e3a1f8867bae18511a9f0aa80dae22b5a4bb81c3 /docs | |
| parent | ddf0dbbd29e556518f5f4baa3c6ba25a9891fe7b (diff) | |
| download | bootstrap-f0124769c9850bea321cbd82d6250b756a52bb52.tar.xz bootstrap-f0124769c9850bea321cbd82d6250b756a52bb52.zip | |
Collapse supports multi-target thanks to @vanduynslagerp (#22713)
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/4.0/components/collapse.md | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/docs/4.0/components/collapse.md b/docs/4.0/components/collapse.md index cbdc50bb7..e1d3e3b64 100644 --- a/docs/4.0/components/collapse.md +++ b/docs/4.0/components/collapse.md @@ -32,6 +32,35 @@ You can use a link with the `href` attribute, or a button with the `data-target` </div> {% endexample %} +## Multiple triggers / targets + +A `<button>` or `<a>` can show and hide multiple elements by referencing them with a JQuery selector in its `href` or `data-target` attribute. +Multiple `<button>` or `<a>` can show and hide an element if they each reference it with their `href` or `data-target` attribute + +{% example html %} +<p> + <a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a> + <button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle second element</button> + <button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button> +</p> +<div class="row"> + <div class="col"> + <div class="collapse multi-collapse" id="multiCollapseExample1"> + <div class="card card-block"> + Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. + </div> + </div> + </div> + <div class="col"> + <div class="collapse multi-collapse" id="multiCollapseExample2"> + <div class="card card-block"> + Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. + </div> + </div> + </div> +</div> +{% endexample %} + ## Accordion example Using the [card]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/card/) component, you can extend the default collapse behavior to create an accordion. @@ -129,7 +158,7 @@ These classes can be found in `_transitions.scss`. ### Via data attributes -Just add `data-toggle="collapse"` and a `data-target` to the element to automatically assign control of a collapsible element. The `data-target` attribute accepts a CSS selector to apply the collapse to. Be sure to add the class `collapse` to the collapsible element. If you'd like it to default open, add the additional class `show`. +Just add `data-toggle="collapse"` and a `data-target` to the element to automatically assign control of one or more collapsible elements. The `data-target` attribute accepts a CSS selector to apply the collapse to. Be sure to add the class `collapse` to the collapsible element. If you'd like it to default open, add the additional class `show`. To add accordion-like group management to a collapsible area, add the data attribute `data-parent="#selector"`. Refer to the demo to see this in action. |
