JS makes the mobile terminal auto scaling display, js makes auto Scaling
JS makes a mobile terminal adaptive scaling display
Example 1:
<script>var _width = parseInt(window.screen.width);var scale = _width/640;var ua = navigator.userAgent.toLowerCase();var result = /android (\d+\.\d+)/.exec(ua);if (result){var version = parseFloat(result[1]);if(version>2.3){document.write('<meta name="viewport" content="width=640, minimum-scale = '+scale+', maximum-scale = '+scale+', target-densitydpi=device-dpi">');}else{document.write('<meta name="viewport" content="width=640, target-densitydpi=device-dpi">');}} else {document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">');}</script>
Example 2:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script><script type="text/javascript">$(function(){ if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) { var viewportmeta = document.querySelector('meta[name="viewport"]'); if (viewportmeta) { viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0'; document.addEventListener('touchstart', function () { viewportmeta.content = 'viewportmeta.content = width=device-width, minimum-scale=0.25, maximum-scale=1.6'; }, false); document.addEventListener('orientationchange', function () { viewportmeta.content = 'viewportmeta.content = width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0'; }, false); } }});</script>
Example 3:
<meta charset="UTF-8"><meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"><meta content="yes" name="apple-mobile-web-app-capable"><meta content="black" name="apple-mobile-web-app-status-bar-style"><meta content="telephone=no" name="format-detection">
Summary:
I. In fact, it is not difficult. First, add a line of viewport meta tag to the header of the webpage code.
<Meta name = "viewport" content = "width = device-width, initial-scale = 1"/>
2. Do not use absolute width because the webpage will adjust the layout according to the screen width, so you cannot use an absolute width layout or an element with an absolute width.
3. The relative font size cannot use absolute size (px), but can only use relative size (em ).
4. fluid grid indicates that the positions of each block are floating, not fixed.
. Main {float: right; width: 70%;}. leftBar {float: left; width: 25% ;}
5. In addition to layout and text, fluid image must automatically scale the image as well as "Adaptive webpage design.
The above is all the content of this article. I hope you will like it.