jQuery Mobile - 縮放影像



說明

能夠橫向和縱向縮放影像。

示例

以下示例演示瞭如何在 jQuery Mobile 框架中使用“縮放影像”。

<!DOCTYPE html>
   <head>
      <title>Scaling Images</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>
      <script src = "http://demos.jquerymobile.com/1.4.5/popup-image-scaling/popup-image-scaling.js"></script>
   </head>
   
   <body>
      <div data-role = "header">
         <h2>Header</h2>
      </div>
      
      <a href = "#popup_landscape" data-rel = "popup" data-position-to = "window" 
         class = "ui-btn ui-btn-inline">Landscape  View</a>
         
      <a href = "#popup_portrait" data-rel = "popup" data-position-to = "window" 
         class = "ui-btn ui-btn-inline" data-transition = "fade">Portrait View</a>
         
      <div data-role = "popup" id = "popup_landscape" class = "photopopup" 
         data-overlay-theme = "a" data-tolerance = "30,15">
         <a href = "#" data-rel = "back" class = "ui-btn ui-btn-a ui-icon-delete 
            ui-btn-icon-notext ui-btn-right">Close</a>
            <img src = "/jquery_mobile/images/blue_hills1.jpg" alt = "Landscape View">
      </div>
      
      <div data-role = "popup" id = "popup_portrait" class = "photopopup" 
         data-overlay-theme = "a" data-tolerance = "30,15">
         <a href = "#" data-rel = "back" class = "ui-btn ui-btn-a ui-icon-delete 
            ui-btn-icon-notext ui-btn-right">Close</a>
            <img src = "/jquery_mobile/images/blue_hills2.jpg" alt = "Portrait View">
      </div>
      
      <div data-role = "footer">
         <h2>Footer</h2>
      </div>
      
   </body>
</html>

輸出

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

  • 將上面的 html 程式碼儲存為伺服器根資料夾中的 jqm_scaling_images.html 檔案。

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.