gpt4 book ai didi

iphone - 如何为响应式设计检测屏幕高度

转载 作者:太空宇宙 更新时间:2023-11-04 04:47:59 26 4
gpt4 key购买 nike

我正在为响应式设计构建一个网站。

我有一定的CSS样式如下:

/* when viewport height less than 320px */
@media screen and (max-height: 319px) { /* TRIED FOR IPHONE -- CAN'T GET TO WORK YET */

#footer {
font-size: 65%;
line-height: 110%;
margin-top: 12px;
}

}

我在我的 iPhone 横向模式下测试它,字体大小没有更改为 65%,这 3 种样式中的任何一种都不生效。这是检测 iPhone 屏幕高度尺寸的有效且正确的方法吗?

最佳答案

您可以尝试使用不同的媒体查询吗?

http://css-tricks.com/snippets/css/media-queries-for-standard-devices/

@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
}

我从来没有遇到过媒体查询的问题。在纵向和横向模式下通过在线 iPhone 模拟器测试您的网站后,字体大小设置为 65%:

http://www.testiphone.com/

但是,如果上面的媒体查询不起作用,您可以尝试更改视口(viewport)吗?

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">

关于iphone - 如何为响应式设计检测屏幕高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14084524/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com