Heim >Web-Frontend >HTML-Tutorial >web页面放到手机页面,缩放问题_html/css_WEB-ITnose
有时候写页面样式不规范,很多页面元素写死尺寸时,web页面尺寸比较大放到移动端访问时,就背缩放了,div或者按钮变得好小
可以加段js,效果会好点
1 <script> 2 ! function( userAgent ) { 3 var screen_w = parseInt(window.screen.width), 4 scale = screen_w / 640; 5 if ( /Android (\d+\.\d+)/.test( userAgent ) ) { 6 var version = parseFloat( RegExp.$1 ); 7 document.write( version > 2.3 8 ? '<meta name="viewport" content="width=640, minimum-scale = ' + scale + ", maximum-scale = " + scale + ', target-densitydpi=device-dpi">' 9 : '<meta name="viewport" content="width=640, target-densitydpi=device-dpi">' );10 } else {11 document.write( '<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">' );12 }13 }( navigator.userAgent );14 15 16 </script>