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

WBOY
Release: 2016-06-24 11:49:33
Original
1392 people have browsed it

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

 

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!