移动端设备分辨率 480*800,但显示尺寸为 320 的兼容问题_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:52:03
Original
1233 people have browsed it

项目:app 客户端内置浏览器嵌套页面
环境:Android webview 内置浏览器,设备分辨率 480*800

页面所有元素的高度、宽度以及边距、字体大小单位都是用的 rem,全部通过 html 的 font-size 来计算,页面有写 

<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui"/>
Copy after login

css 代码:
@media only screen and (min-device-width:361px) and (max-device-width:480px){	html{font-size:44.4444%;}	.viewport{max-width:480px;}}
Copy after login

问题:宽度高度计算的不对,导致界面错位。因为 android 内置的 webview 貌似最小字号只能设置到 8px,而我这边 320 显示的字号是 7px,所以导致界面有问题。
PS:我已试过 html{-webkit-text-size-adjust:none;} 此方法不行
PS2:font-size:44.4444% 是根据 720 分辨率 font-size:100% 折算出来的(320 / 720 = 44.4444%)


回复讨论(解决方案)

如果移动端你是用百分比来设置font-size 的话,请了解下em.

如果移动端你是用百分比来设置font-size 的话,请了解下em.


em:相对父级


如果移动端你是用百分比来设置font-size 的话,请了解下em.


em:相对父级
rem(root element):相对根父级
用 rem 不是更方便

720宽度 显示  100%
480宽度 显示 44%

从实际角度出发 应该都显示  100% 不能因为房间变小了 凳子就变小

从你的业务逻辑看 你采用webkit-transform-scale的css缩放会更好

感谢两位的回答,问题暂时解决了。
解决方法:以 640 为 100%,这样 320 的就是 50% 了,即 8px,而 720 则是 112.5%

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!