jQuery Mobile - Scaling Images



Description

You can scale the image in landscape and portrait format.

Example

Following example demonstrates the use of scaling images in the jQuery Mobile Framework.

<!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>

Output

Let's carry out the following steps to see how the above code works −

  • Save the above html code as jqm_scaling_images.html file in your server root folder.

  • Open this HTML file as http://localhost/jqm_scaling_images.html and the following output will be displayed.

jquery_mobile_widgets.htm
Advertisements