简体   繁体   中英

force same font size on every mobile device

I would like that my site works like the mobile page of facebook. It is independent what the screen resolution is, the navbar etc. are always the same size. How can I achieve this?

This is how I want it on all devices LG Optimus Black (480 x 800 pixel)

这就是我在所有设备上都想要的LG Optimus Black(480 x 800像素)

This is how it looks on my Lumia 920 (1280 x 768 pixel)

这就是我的Lumia 920(1280 x 768像素)上的样子

You will have to use Javascript for this. Here's a jQuery approach:

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
    $('body').addClass("mobile");
}

Then you can style appropriately, eg:

.mobile div {
    width: 100%;
}

CSS media queries will only get you as far as detecting screen size or orientation. There are some but compatibility is an issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM