Mobile website development-viewport-display page by mobile phone size, website development-viewport-
I am writing a mobile phone webpage recently. Two methods are summarized:
1. The webpage width can be fixed to 640px, and the page is displayed on different mobile phone pages using viewport.
Insert script code into the webpage
<script type="text/javascript">if(/Android (\d+\.\d+)/.test(navigator.userAgent)){var version = parseFloat(RegExp.$1);if(version>2.3){var phoneScale = parseInt(window.screen.width)/640;document.write('<meta name="viewport" content="width=640, minimum-scale = '+ phoneScale +', maximum-scale = '+ phoneScale +', 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">');}</script>
2. Cut the graph by percentage
Add<
meta
name
=
"viewport"
content
=
"width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"
/>