Set an Accordion on a Section Element
If you want a topic to use an accordion wherever that topic appears, give the topic's section
element a role
attribute with value set to accordion:
-
In the Content Manager, find the topic (or informal topic) and select it to open it in the editor.
-
In the Element Structure Menu, select a
section
element orsidebar
element and then select Go to element.Note
It is possible to have multiple
section
elements in a topic. The first (leftmost)section
represents the topic as a whole. Any othersection
elements are for subsections inside the topic. We recommend that you create subsections by inserting a topic as a component inside another topic rather than create asection
inside asection
. -
Select Add attribute in the Element Attributes Panel.
-
Enter
Role
and select it from the menu. -
Enter
accordion
as therole
attribute value. -
Select Save.
-
Select Layout and then select the Layout you are going to use for publishing. Make sure that the Output role attribute as class names setting is enabled (for details, see Enable Output Role Attribute as Class Names). Accordions will not work if this setting is disabled.
When you publish to HTML5 or Zendesk, the section
or sidebar
will appear as an accordion (when it is a subsection of another topic).
Tip
You can style the accordion by using custom CSS.
For example, if you want a background color for the header, create a CSS file (or edit an existing one) and use:
.panel-default > .panel-heading { background-color: #fafafa; padding: 1em; }
You can then upload the CSS to your Layout (see Upload Customized CSS).