content-collapsible-set.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>jQuery Mobile Docs - Collapsible Content</title>
  7. <link rel="stylesheet" href="../../jquery.mobile-1.0.1.min.css" />
  8. <link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
  9. <script src="../../jquery.js"></script>
  10. <script src="../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
  11. <script src="../_assets/js/jqm-docs.js"></script>
  12. <script src="../../jquery.mobile-1.0.1.min.js"></script>
  13. </head>
  14. <body>
  15. <div data-role="page" class="type-interior">
  16. <div data-role="header" data-theme="f">
  17. <h1>Collapsible sets (Accordions)</h1>
  18. <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
  19. </div><!-- /header -->
  20. <div data-role="content">
  21. <div class="content-primary">
  22. <h2>Collapsible set markup</h2>
  23. <p>Collapsible sets start with the exact same markup as <a href="content-collapsible.html">individual collapsibles</a>. By adding a parent wrapper with a <code> data-role="collapsible-set"</code> attribute around a number of collapsibles, the framework will style these to looks like a visually grouped widget and make it behave like an accordion so only one section can be open at a time. View the <a href="../api/data-attributes.html">data- attribute reference</a> to see all the possible attributes you can add to collapsible sets.</p>
  24. <p>By default, all the sections will be collapsed. To set a section to be open when the page loads, add the <code> data-collapsed="false"</code> attribute to the heading of the section you want expanded.</p>
  25. <pre><code>
  26. <strong>&lt;div data-role="collapsible-set"&gt;</strong>
  27. &lt;div data-role=&quot;collapsible&quot; <strong>data-collapsed=&quot;false&quot;</strong>&gt;
  28. &lt;h3&gt;Section 1&lt;/h3&gt;
  29. &lt;p&gt;I&#x27;m the collapsible set content for section B.&lt;/p&gt;
  30. &lt;/div&gt;
  31. &lt;div data-role=&quot;collapsible&quot;&gt;
  32. &lt;h3&gt;Section 2&lt;/h3&gt;
  33. &lt;p&gt;I&#x27;m the collapsible set content for section B.&lt;/p&gt;
  34. &lt;/div&gt;
  35. <strong>&lt;/div&gt;</strong>
  36. </code></pre>
  37. <p>Here is an example of a collapsible set with 5 sections.</p>
  38. <div data-role="collapsible-set">
  39. <div data-role="collapsible" data-collapsed="false">
  40. <h3>Section 1</h3>
  41. <p>I'm the collapsible content in a set so this feels like an accordion. I'm open by default because I have the <code>data-collapsed="false"</code> attribute.</p>
  42. </div>
  43. <div data-role="collapsible">
  44. <h3>Section 2</h3>
  45. <p>I'm the collapsible content in a set so this feels like an accordion. I'm hidden by default because I have the "collapsed" state; you need to expand the header to see me.</p>
  46. </div>
  47. <div data-role="collapsible">
  48. <h3>Section 3</h3>
  49. <p>I'm the collapsible content in a set so this feels like an accordion. I'm hidden by default because I have the "collapsed" state; you need to expand the header to see me.</p>
  50. </div>
  51. <div data-role="collapsible">
  52. <h3>Section 4</h3>
  53. <p>I'm the collapsible content in a set so this feels like an accordion. I'm hidden by default because I have the "collapsed" state; you need to expand the header to see me.</p>
  54. </div>
  55. <div data-role="collapsible">
  56. <h3>Section 5</h3>
  57. <p>I'm the collapsible content in a set so this feels like an accordion. I'm hidden by default because I have the "collapsed" state; you need to expand the header to see me.</p>
  58. </div>
  59. </div>
  60. <h2>Theming collapsible content</h2>
  61. <p>The standard <code>data-theme</code> attribute can be used to set the color of each collapsible in a set. To provide a clearer visual grouping of the content with the headers, add the <code>data-content-theme</code> attribute with a swatch letter. This adds a themed background color and border to the content block. For consistent theming, add these attributes to the parent collapsible set.</p>
  62. <pre><code>
  63. &lt;div data-role=&quot;collapsible-set&quot; <strong>data-theme=&quot;c&quot; data-content-theme=&quot;d&quot;</strong>&gt;
  64. </code></pre>
  65. <div data-role="collapsible-set" data-theme="c" data-content-theme="d">
  66. <div data-role="collapsible">
  67. <h3>Section 1</h3>
  68. <p>Collapsible content</p>
  69. </div>
  70. <div data-role="collapsible">
  71. <h3>Section 2</h3>
  72. <p>Collapsible content</p>
  73. </div>
  74. <div data-role="collapsible">
  75. <h3>Section 3</h3>
  76. <p>Collapsible content</p>
  77. </div>
  78. </div>
  79. <h2>Theming individual sections</h2>
  80. <p>To have individual sections in a group styled differently, add <code>data-theme</code> and <code>data-content-theme</code> attributes to specific collapsibles.</p>
  81. <div data-role="collapsible-set" data-content-theme="c">
  82. <div data-role="collapsible" data-theme="b" data-content-theme="b">
  83. <h3>Section header, swatch B</h3>
  84. <p>Collapsible content, swatch B</p>
  85. </div>
  86. <div data-role="collapsible" data-theme="a" data-content-theme="a">
  87. <h3>Section header, swatch A</h3>
  88. <p>Collapsible content, swatch A</p>
  89. </div>
  90. <div data-role="collapsible" data-theme="e" data-content-theme="d">
  91. <h3>Section header, swatch E</h3>
  92. <p>Collapsible content, swatch D</p>
  93. </div>
  94. </div>
  95. </div><!--/content-primary -->
  96. <div class="content-secondary">
  97. <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
  98. <h3>More in this section</h3>
  99. <ul data-role="listview" data-theme="c" data-dividertheme="d">
  100. <li data-role="list-divider">Content Formatting</li>
  101. <li><a href="content-html.html">Basic HTML styles</a></li>
  102. <li><a href="content-grids.html">Layout grids (columns)</a></li>
  103. <li><a href="content-collapsible.html">Collapsible content blocks</a></li>
  104. <li data-theme="a"><a href="content-collapsible-set.html">Collapsible sets (accordions)</a></li>
  105. <li><a href="content-themes.html">Theming content</a></li>
  106. </ul>
  107. </div>
  108. </div>
  109. </div><!-- /content -->
  110. <div data-role="footer" class="footer-docs" data-theme="c">
  111. <p>&copy; 2011-2012 The jQuery Project</p>
  112. </div>
  113. </div><!-- /page -->
  114. </body>
  115. </html>