2013-12-08 38 views
1

在任何主要的5個最新瀏覽器中都能正常工作,但不能在任何移動設備上正常工作,不知道爲什麼。Media Querys在桌面瀏覽器中工作,但不支持移動

這是我的代碼

/* Desktop */ 
@import url("desktop.css"); 

/* Small Phone */ 
@import url("smallMobile.css") only screen and (max-width:320px); 

/* Large Phone and small Tablet */ 
@import url("largeMobile-smallTablet.css") only screen and (min-width:321px) and (max-width:600px); 

/*片劑和小桌面*/ @import URL( 「片劑smallDesktop.css」)僅屏幕和(最小寬度:601px)和(MAX-寬度:1120px);

回答

0

嘗試

@media only screen and (min-width:321px) and (max-width:600px) { 
    @import url("largeMobile-smallTablet.css"); 
} 

@media only screen and (min-device-width:321px) and (max-device-width:600px) { 
    @import url("largeMobile-smallTablet.css"); 
} 
+0

這一切都沒有工作抱歉,謝謝 – user3001499

0

使用device-width,並確保你知道你要定位的手機;新的iPhone有不同的device-pixel-ratio值能改變device-width

這裏有不同的iPhone的媒體查詢(這裏看看比較常見的尺寸,https://css-tricks.com/snippets/css/media-queries-for-standard-devices/):

/* ----------- iPhone 4 and 4S ----------- */ 

/* Portrait and Landscape */ 
@media only screen 
    and (min-device-width: 320px) 
    and (max-device-width: 480px) 
    and (-webkit-min-device-pixel-ratio: 2) { 

} 


/* ----------- iPhone 5 and 5S ----------- */ 

/* Portrait and Landscape */ 
@media only screen 
    and (min-device-width: 320px) 
    and (max-device-width: 568px) 
    and (-webkit-min-device-pixel-ratio: 2) { 

} 

/* ----------- iPhone 6 ----------- */ 

/* Portrait and Landscape */ 
@media only screen 
    and (min-device-width: 375px) 
    and (max-device-width: 667px) 
    and (-webkit-min-device-pixel-ratio: 2) { 

} 


/* ----------- iPhone 6+ ----------- */ 

/* Portrait and Landscape */ 
@media only screen 
    and (min-device-width: 414px) 
    and (max-device-width: 736px) 
    and (-webkit-min-device-pixel-ratio: 3) { 

} 

而對於ipad公司:

/* ----------- iPad 1 and 2 ----------- */ 
/* Portrait and Landscape */ 
@media only screen 
    and (min-device-width: 768px) 
    and (max-device-width: 1024px) 
    and (-webkit-min-device-pixel-ratio: 1) { 

} 

/* ----------- iPad 3 and 4 ----------- */ 
/* Portrait and Landscape */ 
@media only screen 
    and (min-device-width: 768px) 
    and (max-device-width: 1024px) 
    and (-webkit-min-device-pixel-ratio: 2) { 

} 
相關問題