2

我必须创建两个版本的网络应用程序:一个用于横向,一个用于纵向。但我需要像我们通常在 iPad 中那样运行它们;在纵向模式下,纵向版本应该可以工作,如果模式是横向,那么横向版本。

如何用一个 HTML 文件和两个 CSS 文件制作网站?

4

4 回答 4

5

use the css3 media query

/* iPads (landscape) */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape) {
/* Styles */
}

/* iPads (portrait) */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) {
/* Styles */
}
于 2012-11-09T04:51:50.607 回答
2

Look into responsive design. Twitter's Bootstrap project includes a series of responsive layouts, but the method is pretty basic: you define your CSS based on the current width of the device.

http://twitter.github.com/bootstrap/scaffolding.html#responsive

Here's an article explaining CSS3 and media queries: http://webdesignerwall.com/tutorials/responsive-design-with-css3-media-queries

于 2012-11-09T04:52:44.550 回答
1

以下是css media queries标准设备:-

/* Smartphones (portrait and landscape) ----------- */
@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) {
/* Styles */
}

/* Smartphones (landscape) ----------- */
@media only screen 
and (min-width : 321px) {
/* Styles */
}

/* Smartphones (portrait) ----------- */
@media only screen 
and (max-width : 320px) {
/* Styles */
}

/* iPads (portrait and landscape) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) {
/* Styles */
}

/* iPads (landscape) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape) {
/* Styles */
}

/* iPads (portrait) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) {
/* Styles */
}

/* Desktops and laptops ----------- */
@media only screen 
and (min-width : 1224px) {
/* Styles */
}

/* Large screens ----------- */
@media only screen 
and (min-width : 1824px) {
/* Styles */
}

/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
于 2012-11-09T05:00:47.523 回答
0

这个可以帮助你

http://ajaxian.com/archives/iphone-windowonorientationchange-code

它检测浏览器的方向变化并调用java Script函数。在函数内部,您可以根据自己的喜好加载您的css 类:)

于 2012-11-09T05:07:00.063 回答