Home  >  Article  >  Web Front-end  >  The web page is placed on the mobile page, scaling problem_html/css_WEB-ITnose

The web page is placed on the mobile page, scaling problem_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:49:331422browse

有时候写页面样式不规范,很多页面元素写死尺寸时,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>

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn