jQuery Mobile - 主题类型

描述

您可以在按钮、导航栏、块、链接等上设置不同类型的主题。 您可以使用 data-theme 属性设置主题。


示例

下面的示例演示了在 jQuery Mobile 框架中使用 themes 主题

<!DOCTYPE html>
<html>
   <head>
      <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 = "page" id = "pageone" data-theme = "a">
         <div data-role = "panel" id = "panel1">
            <h2>This is Panel Header</h2>
            <p>You can close this panel by pressing the Esc key or by swiping.</p>
         </div>
         
         <div data-role = "header">
            <h2>Header</h>
         </div>
         
         <div data-role = "main" class = "ui-content">
            <button class = "ui-btn">Button</button>
            <p>Click on the button to open Panel.</p>
            <a href = "#panel1" class = "ui-btn ui-btn-inline">Open Panel</a>
            <p>List View:</p>
            <ul data-role = "listview" data-autodividers = "true">
               <li><a href = "#">India</a></li>
               <li><a href = "#">England</a></li>
               <li><a href = "#">Srilanka</a></li>
            </ul><br>
            <a href = "#popup_menu" data-rel = "popup" data-transition = "slidedown" 
               class = "ui-btn ui-btn-inline ui-icon-home ui-btn-icon-left ui-btn-a">
               Click to see menu items</a>
            
            <div data-role = "popup" id = "popup_menu" data-theme = "a">
               <ul data-role = "listview">
                  <li data-role = "list-divider">Select your choice</li>
                  <li><a href = "#">India</a></li>
                  <li><a href = "#">Srilanka</a></li>
                  <li><a href = "#">Australia</a></li>
                  <li><a href = "#">England</a></li>
               </ul>
            </div>
         </div>
         
         <div data-role = "footer">
            <h2>Footer</h2>
         </div>
      </div>
      
   </body>
</html>

输出

让我们执行以下步骤,看看上面的代码是如何工作的 −

  • 将上述 html 代码保存为服务器根文件夹中的 jqm_themes_types.html 文件。

  • 将此 HTML 文件打开为 http://localhost/jqm_themes_types.html,将显示以下输出。

❮ jQuery Mobile - 小部件