简体   繁体   English

调整媒体查询以处理iPhone 5

[英]Adjust media query to handle iphone 5

I have a web page that displays properly for an iphone 6. Is there an easy way to adjust the screen size with a media query for an iphone 5 so everything will shrink down properly? 我有一个可以正确显示iphone 6的网页。是否有一种简单的方法可以通过对iphone 5的媒体查询来调整屏幕尺寸,以便所有内容都能正确缩小?

I know how to trigger CSS for an Iphone 5 what I'm looking for is a way to easily set up CSS so it's just one CSS command to reformat for the iphone 5. Let's say you have it all working for an Iphone 6, could we just set a reduced width for Iphone 5 and have everything automatically scale down? 我知道如何为Iphone 5触发CSS,我正在寻找一种可以轻松设置CSS的方法,因此,这只是为Iphone 5重新格式化的一个CSS命令。假设您对Iphone 6都可以使用,我们只是为Iphone 5设置了减小的宽度,然后是否自动缩小了所有内容?

Only iPhone 5 (portrait mode) 仅iPhone 5(人像模式)

@media only screen and (min-device-width: 320px) and (max-device-width: 568px)
and (-webkit-device-pixel-ratio: 2) and (device-aspect-ratio: 40/71) and (orientation:portrait)
{
   ...
}

Only iPhone 5 (landscape mode) 仅iPhone 5(横向模式)

@media only screen and (min-device-width: 320px) and (max-device-width: 568px)
and (-webkit-device-pixel-ratio: 2) and (device-aspect-ratio: 40/71) and (orientation:landscape)
{
   ...
}

Another useful media feature is 另一个有用的媒体功能是

device-aspect-ratio

Note that the iPhone 5 does not have a 16:9 aspect ratio. 请注意,iPhone 5没有16:9的宽高比。 It is in fact 40:71. 实际上是40:71。

iPhone 5:
@media screen and (device-aspect-ratio: 40/71) {}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM