The SpryAccordion.css file provides the default styling for the Accordion widget. You can, however, easily customize the widget by changing the appropriate CSS. The CSS rules in the SpryAccordion.css file use the same class names as the related elements in the accordion’s HTML code, so it’s easy for you to know which CSS rules correspond to the different sections of the Accordion widget. Additionally, the SpryAccordion.css file contains class names for widget behaviors (for example, hovering and clicking behaviors).
The SpryAccordion.css file should already be included in your website before you start customizing. For more information, see Prepare your files.
Set properties for the entire Accordion widget container, or set properties for the components of the widget individually.
You can replace style-related class names in the SpryAccordion.css file and HTML code with class names of your own. Doing so does not affect the functionality of the widget.
The SpryAccordion.css file contains extensive comments, explaining the code and the purpose for certain rules. For further information, see the comments in the file.
Set properties for the entire Accordion widget container, or set properties for the components of the widget individually.
Text to change |
Relevant CSS rule |
Example of properties and values to add |
---|---|---|
Text in the entire accordion (includes both tab and content panel) |
.Accordion or .AccordionPanel |
font: Arial; font-size:medium; |
Text in accordion panel tabs only |
.AccordionPanelTab |
font: Arial; font-size:medium; |
Text in accordion content panels only |
.AccordionPanelContent |
font: Arial; font-size:medium; |
Part of widget to change |
Relevant CSS rule |
Example of property and value to add or change |
---|---|---|
Background color of accordion panel tabs |
.AccordionPanelTab |
background-color: #CCCCCC; (This is the default value.) |
Background color of accordion content panels |
.AccordionPanelContent |
background-color: #CCCCCC; |
Background color of the open accordion panel |
.AccordionPanelOpen .AccordionPanelTab |
background-color: #EEEEEE; (This is the default value.) |
Background color of panel tabs on hover |
.AccordionPanelTabHover |
color: #555555; (This is the default value.) |
Background color of open panel tab on hover |
.AccordionPanelOpen .AccordionPanelTabHover |
color: #555555; (This is the default value.) |
By default, the Accordion widget expands to fill available space. To constrain the width of an Accordion widget, set a width property for the accordion container.
By default, the height of Accordion widget panels is set to 200 pixels. To change the height of panels, change the height property in the .AccordionPanelContent rule.
The Accordion widget includes some predefined behaviors. These behaviors consist of changing CSS classes when a particular event occurs. For example, when a mouse pointer hovers over an accordion panel tab, Spry applies the AccordionPanelTabHover class to the widget. (This behavior is similar to a:hover for links.) The behaviors are blank by default; to change them, add properties and values to the rules.
<script type="text/javascript"> var acc2 = new Spry.Widget.Accordion("Accordion2", { hoverClass: "hover", openClass: "open", closedClass: "closed", focusedClass: "focused" }); </script>
By default, accordion panels use animation to smoothly open and close. You can turn this animation off so that the panels instantly open and close.
<script type="text/javascript"> var acc5 = new Spry.Widget.Accordion("Accordion5", { enableAnimation: false }); </script>
You can change the time it takes for a panel to open. Set the time in milliseconds (1000 = 1 second). By default, Spry uses 500 milliseconds (0.5 seconds).
<script type="text/javascript"> var acc9 = new Spry.Widget.Accordion("Accordion9", { duration: 1000 }); </script>
By default, when animation is enabled, Spry forces all accordion content panels to use the same height. Spry derives this height from the height of the default open panel of the accordion, which is determined by CSS or by the height of the content in the panel.
The accordion also supports variable height panels. To turn this support on, pass a useFixedPanelHeights: false option to the accordion's constructor.
<script type="text/javascript"> var acc7 = new Spry.Widget.Accordion("Accordion7", { useFixedPanelHeights: false }); </script>
For an example, see the Accordion sample file located in the samples directory of the Spry directory that you downloaded from Adobe Labs. For more information, see Prepare your files.
You can also specify a panel height in the Accordion constructor, rather than in the CSS, by using the fixedPanelHeight constructor option. The value for the fixedPanelHeight constructor option should be an integer that specifies the height of the panel in pixels.
<script type="text/javascript"> var acc7 = new Spry.Widget.Accordion("Accordion7", { fixedPanelHeight: "300" }); </script>