jQuery Mobile - 頁面滑動淡入淡出過渡



描述

你可以使用 data-transition = "slidefade" 屬性從右向左滑動頁面,並逐漸淡入下一頁。

示例

下列示例描述了 jQuery Mobile 框架中頁面滑動淡入淡出的用法。

<!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 = "page1">
         <div data-role = "header">
            <h2>Header</h2>
         </div>
         
         <div data-role = "main" class = "ui-content">
            <p>Welcome to Tutorialspoint!!! Click the link to slide from right to left 
            and fades in the next page.</p>
            <a href = "#page2" data-transition = "slidefade">Page Two</a>
         </div>
         
         <div data-role = "footer">
            <h2>Footer</h2>
         </div>
      </div>

      <div data-role = "page" id = "page2">
         <div data-role = "header">
            <h2>Header</h2>
         </div>

         <div data-role = "main" class = "ui-content">
            <p>Click the link to go page one.</p>
            <a href = "#page1">Page One</a>
         </div>

         <div data-role = "footer">
            <h2>Footer</h2>
         </div>
      </div>
      
   </body>
</html>

輸出

讓我們執行以下步驟,看看上述程式碼如何執行 −

  • 將上述 html 程式碼另存為 page_slidefade.html 檔案,放到你的伺服器根資料夾中。

  • 開啟此 HTML 檔案為 https:///page_slidefade.html,將顯示以下輸出。

jquery_mobile_transitions.htm
廣告
© . All rights reserved.