Tuesday, November 8, 2011

viewport for Mobile device

If you try the examples in former post, you will get difference appearance on difference browser, even on the same device. We haven't take care about the viewport for mobile device. You can override the default viewport by including a viewport meta tag in the <head> section of your page.

example:
<!DOCTYPE html>
<html>
<head>
<meta name = "viewport" content = "width = device-width, height = device-height" />
<title>jQuery Mobile: Dialog</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.css" />
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
</head>
<body>

<div data-role="page" id="home">
<div data-role="header">
<h1>Open Dialog</h1>
</div>
<div data-role="content">
<p>Hello ALL</p>
<p>jQuery Mobile: Dialog</p>
<a href="#dialog" data-rel="dialog" data-transition="pop">Open Dialog</a>
</div>
<div data-role="footer">
<h4><a href="http://mobile-web-app.blogspot.com/">http://mobile-web-app.blogspot.com/</a></h4>
</div>
</div>

<div data-role="page" id="dialog">
<div data-role="header">
<h1>mobile-web-app</h1>
</div>
<div data-role="content">
<p>It's a Dialog</p>
<input type="button" value="Close Dialog" onclick="button_clicked()" />
</div>
<div data-role="footer">
<h4><a href="http://mobile-web-app.blogspot.com/">http://mobile-web-app.blogspot.com/</a></h4>
</div>
</div>
<script>
function button_clicked(){
$('.ui-dialog').dialog ('close');
}
</script>
</body>
</html>



Android default browser
Firefox on Android
Opera Mobile on Android

No comments:

Post a Comment