2017-09-20 5 views
17

Welche CSS-Medienabfragen entsprechen den neuen Apple-Geräten? Ich muss die body 's background-color einstellen, um die Hintergrundfarbe des sicheren Bereichs des X zu ändern.iPhone X/8/8 Plus CSS-Medienabfragen

Antwort

39

iPhone X

@media only screen 
    and (device-width : 375px) 
    and (device-height : 812px) 
    and (-webkit-device-pixel-ratio : 3) { } 

iPhone 8

@media only screen 
    and (device-width : 375px) 
    and (device-height : 667px) 
    and (-webkit-device-pixel-ratio : 2) { } 

iPhone 8 Plus

@media only screen 
    and (device-width : 414px) 
    and (device-height : 736px) 
    and (-webkit-device-pixel-ratio : 3) { } 


iPhone 6 +/6s +/7 +/8 + teilen die gleichen Größen, während das iPhone 7/8 auch tun.


der Suche nach einer bestimmten Orientierung?

Portrait

Fügen Sie die folgende Regel:

and (orientation : portrait) 

Landschaft

Fügen Sie die folgende Regel:

and (orientation : landscape) 



Referenzen:

3

Hier sind einige der folgenden Medienabfragen für iPhones. Ref Link https://mydevice.io/devices/

/* iphone 3 */ 
@media only screen and (min-device-width: 320px) and (max-device-height: 480px) and (-webkit-device-pixel-ratio: 1) { } 

/* iphone 4 */ 
@media only screen and (min-device-width: 320px) and (max-device-height: 480px) and (-webkit-device-pixel-ratio: 2) { } 

/* iphone 5 */ 
@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (-webkit-device-pixel-ratio: 2) { } 

/* iphone 6, 6s */ 
@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (-webkit-device-pixel-ratio: 2) { } 

/* iphone 7, 8 */ 
@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (-webkit-device-pixel-ratio: 2) { } 

/* iphone 6+, 6s+, 7+, 8+ */ 
@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (-webkit-device-pixel-ratio: 3) { } 

/* iphone X */ 
@media only screen and (min-device-width: 375px) and (max-device-height: 812px) and (-webkit-device-pixel-ratio: 3) { } 
+0

Sie sollen Referenzen hinzufügen, zum Beispiel: Links zu anderen SO Antworten, wenn man sie kopiert. – nathan

+0

@nathan Antwort aktualisiert. –

Verwandte Themen