jQuery Mobile 可摺疊集合主題



描述

可透過向可摺疊集合新增 data-theme 屬性,來設定每個可摺疊標頭的顏色。

若要指定內容的顏色,可新增 data-content-theme 屬性。可透過向特定可摺疊新增 data-theme 和 data-content-theme 屬性,對組中的各個部分進行不同的樣式設定。

示例

以下示例演示了在 jQuery Mobile 中使用可摺疊主題

<!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_theme.html 檔案。

  • 以 https:///collapsible_set_theme.html 的形式開啟此 HTML 檔案,將顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.