标签:android style io ar color os 使用 sp java
最近在写手机网页,总结两个方法
1. 网页宽度可固定为640px,然后使用viewport实现页面在不同手机页面显示
网页中插入script代码
<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.按照百分比切图
页面中加入<
meta
name
=
"viewport"
content
=
"width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"
/>
标签:android style io ar color os 使用 sp java
原文地址:http://blog.csdn.net/yixiao_naihe/article/details/41647715