Jquery-mobile-collapsible-set-theme

提供:Dev Guides
移動先:案内検索

jQuery Mobile-折りたたみセットテーマ

説明

折りたたみ可能な各ヘッダーの色は、折りたたみ可能なセットにdata-theme属性を追加することで設定できます。

コンテンツの色を指定するには、data-content-theme属性を追加できます。 データテーマとデータコンテンツテーマの属性を特定の折りたたみ可能アイテムに追加することで、グループ内の個々のセクションに異なるスタイルを設定できます。

次の例は、jQuery Mobileでの_collapsible theme_の使用を示しています。

<!DOCTYPE html>
<html>
   <head>
      <title>Collapsible set theme</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>

   <body>
      <div data-role = "collapsibleset" data-theme = "b" data-content-theme = "b">
         <div data-role = "collapsible">
            <h3>Heading</h3>
            <p>This is collapsible content</p>
         </div>

         <div data-role = "collapsible">
            <h3>Heading</h3>
            <p>This is collapsible content</p>
         </div>
      </div>

      <p>You can differently style individual sections in a group by adding
      <i>data-theme</i> and <i>data-content-theme</i> attributes to
      specific collapsibles.</p>

      <div data-role = "collapsibleset" data-theme = "b" data-content-theme = "b">
         <div data-role = "collapsible">
            <h3>Heading</h3>
            <p>This is collapsible content</p>
         </div>

         <div data-role = "collapsible" data-theme = "a" data-content-theme = "a">
            <h3>Heading</h3>
            <p>This is collapsible content</p>
         </div>

         <div data-role = "collapsible">
            <h3>Heading</h3>
            <p>This is collapsible content</p>
         </div>
      </div>
   </body>
</html>

出力

上記のコードがどのように機能するかを確認するために、次の手順を実行してみましょう-

  • 上記のhtmlコードを collapsible_set_themel ファイルとしてサーバーのルートフォルダーに保存します。
  • このHTMLファイルをhttp://localhost/collapsible_set_themelとして開くと、次の出力が表示されます。