1 css css3 media-queries twitter-bootstrap
我有这些媒体查询为iPhone 4和iPhone 5应用不同的样式
/* iPhone 4 (landscape) */
@media only screen and (min-width:320px) and (max-width:480px) and (orientation:landscape) {
.background img {
height: 5px;
}
}
/* iPhone 4 (portrait) */
@media only screen and (min-width:320px) and (max-width:480px) and (orientation:portrait) {
.background img {
height: 10px;
}
}
/* iPhone 5 (landscape) */
@media only screen and (min-width:320px) and (max-width:568px) and (orientation:landscape) {
.background img {
height: 245px;
}
.logo img {
height: 205px;
width: 205px;
}
}
/* iPhone 5 (portrait) */
@media only screen and (min-width:320px) and (max-width:568px) and (orientation:portrait) {
.background img {
height: 210px;
}
.logo img {
height: 170px;
width: 170px;
}
.top-content h2 {
font-size: 1.8em;
line-height: 120%;
margin-bottom: 20px;
}
.main-container {
margin-top: 30px;
margin-left: 15px;
margin-right: 15px;
}
}
Run Code Online (Sandbox Code Playgroud)
问题是在iPhone 5上,iPhone 4的样式也适用.我怎么能阻止这个?
Ada*_*eld 11
另一个有用的媒体功能是设备纵横比.
请注意,iPhone 5的宽高比不是16:9.实际上是40:71.
iPhone < 5:
@media screen and (device-aspect-ratio: 2/3) {}
iPhone 5:
@media screen and (device-aspect-ratio: 40/71) {}
iPad:
@media screen and (device-aspect-ratio: 3/4) {}
Run Code Online (Sandbox Code Playgroud)
参考:媒体查询@ W3C