我必須創建兩個版本的Web應用程序:一個用於橫向,一個用於縱向。但我需要像我們通常在iPad上那樣運行這些;在縱向模式下,縱向版本應該可以工作,如果模式是橫向,那麼橫向版本。如何使用兩個CSS文件設置一個HTML文件的樣式?
如何製作一個HTML文件和兩個CSS文件的網站?
我必須創建兩個版本的Web應用程序:一個用於橫向,一個用於縱向。但我需要像我們通常在iPad上那樣運行這些;在縱向模式下,縱向版本應該可以工作,如果模式是橫向,那麼橫向版本。如何使用兩個CSS文件設置一個HTML文件的樣式?
如何製作一個HTML文件和兩個CSS文件的網站?
使用CSS3媒體查詢
/* 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 */
}
查找到響應式設計。 Twitter的Bootstrap項目包含一系列響應式佈局,但該方法非常基礎:您可以根據設備的當前寬度定義CSS。
http://twitter.github.com/bootstrap/scaffolding.html#responsive
下面是一篇文章,解釋CSS3和媒體查詢:http://webdesignerwall.com/tutorials/responsive-design-with-css3-media-queries
NullPointer的答案給出的結構,並張貼第一。我會給他獎勵點數。 http://stackoverflow.com/a/13302283/1795053 –
這裏是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 */
}
這人會幫助你
http://ajaxian.com/archives/iphone-windowonorientationchange-code
它檢測瀏覽器的方向更改並調用Java腳本函數。裏面的功能,你可以加載你的css類作爲你的首選:)
完美這爲ipad ......... –
東西更酷[實時測試](http://cssmediaqueries.com/) –
這是好的,但如何設置圖像,如果我們有protrait模式圖像尺寸很低,並在風景中兔子太大,所以如何解決這個問題 – user1808433