我試圖設計一個網站,根據用戶的設備來響應地顯示桌面版本或移動版本。我更喜歡使用響應式CSS來做到這一點,而不是使用移動重定向。媒體查詢不適用於iPhone或Android,未完全在桌面上工作
有問題的網站是http://www.raceweekend.com。當瀏覽器窗口的尺寸調整爲移動寬度,以下是應該發生:
- 水平菜單應紅色的矩形塊成爲垂直
- 旋轉圖像應該消失
- 標誌應成爲中心在頂部
- 日期(旁邊的標誌)應該消失
CSS的行爲到底我希望它在這兩個IE9和Firefox。當我調整窗口的尺寸時,所有上述項目都會發生。
在手機上,它只顯示常規瀏覽器版本;上述項目都沒有發生。我在iPhone 4和三星Galaxy Nexus上測試過。
這裏是我的媒體查詢代碼:
@media handheld, screen and (max-width: 480px) {
#nav-bar {
display:none;
}
#header {
height:auto !important;
width:100% !important;
}
#nav {
height:auto !important;
}
.main-nav li {
float:none !important;
clear:both;
background-color:#cf171f;
margin-bottom:1px !important;
padding:0 !important;
}
.main-nav li a{
display:block;
padding:10px 18px;
}
.main-nav li a:hover{
background-color:#be161d;
color:#ffffff !important;
}
#date {
display:none;
}
#race-logo {
width: 100% !important;
}
.center {
margin: 0px auto;
display: block;
}
#content, #content-sliders {
margin-left:5% !important;
width: 90% !important;
padding-top:20px !important;
}
#footer {
font-size:14px !important;
line-height:1.5em;
}
}
謝謝!完美工作! – 2013-02-13 21:47:34