如何根据设备调整网页大小

How to resize webpage depending on the device

本文关键字:网页 调整 何根      更新时间:2023-09-26

有人知道javascript吗?它可以检测用户使用的是手机还是普通电脑,然后调整窗口大小以适应该设备,如果无法使用javascript完成,有人知道它的实现方法吗。

感谢您为提供的任何帮助

粉碎杂志的精彩文章

http://coding.smashingmagazine.com/2010/07/19/how-to-use-css3-media-queries-to-create-a-mobile-version-of-your-website/#more-50749

eq。

 @media only screen and (max-device-width: 480px) {
        // insert styling here… 
 }

我使用这些:

/* Non-Retina */
@media screen and (-webkit-max-device-pixel-ratio: 1) {
}
/* Retina */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
}
/* iPhone Portrait */
@media screen and (max-device-width: 480px) and (orientation:portrait) {
} 
/* iPhone Landscape */
@media screen and (max-device-width: 480px) and (orientation:landscape) {
}
/* iPad Portrait */
@media screen and (min-device-width: 481px) and (orientation:portrait) {
}
/* iPad Landscape */
@media screen and (min-device-width: 481px) and (orientation:landscape) {
}

http://zsprawl.com/iOS/2012/03/css-for-iphone-ipad-and-retina-displays/