I wish to target a css class only to iphones 4, 5, 6 and 6 plus I used this article but wonder if I could not factorize this. Indeed it seems to me that the first 2 device targeting (min width 320/max max width 480px and 568px, I could just use the largest max width and fuse them into only one declaration. It feels my code is just not clean enough and rather repetitive.
Here is my current code:
.example {
@media
//iphone 4
(min-device-width: 320px)
and (max-device-width: 480px)
and (-webkit-min-device-pixel-ratio: 2)
and (orientation: portrait),
//iphone 5
(min-device-width: 320px)
and (max-device-width: 568px)
and (-webkit-min-device-pixel-ratio: 2)
and (orientation: portrait),
//iphone 6
(min-device-width: 375px)
and (max-device-width: 667px)
and (-webkit-min-device-pixel-ratio: 2)
and (orientation: portrait),
//iphone 6+
(min-device-width: 414px)
and (max-device-width: 736px)
and (-webkit-min-device-pixel-ratio: 3)
and (orientation: portrait) {
color: yellow;
}
}
Could I transform/factorize the aobve code into what follows ?
.example {
@media
//mix iphone 4 and 5
(min-device-width: 320px)
and (max-device-width: 568pxpx)
and (-webkit-min-device-pixel-ratio: 2)
and (orientation: portrait),
//iphone 6
(min-device-width: 375px)
and (max-device-width: 667px)
and (-webkit-min-device-pixel-ratio: 2)
and (orientation: portrait),
//iphone 6+
(min-device-width: 414px)
and (max-device-width: 736px)
and (-webkit-min-device-pixel-ratio: 3)
and (orientation: portrait) {
color: red
}
}
Also does this mean some android devices, such as for example the Samsung Galaxy 3 has same width as iphone 4 (320px), will also have the red color applied by my class 'example' ?