我的网站有固定的视口宽度1300‘s。我在iOS的safari中发现了一些固定元素的奇怪行为。没有其他浏览器能做到这一点。
因此,我创建了一个测试页面(下面是代码)。它有3个divs静态,绝对,固定。全部100%宽度。视口设置为1300 to。还有一个简单的js打印每个div的宽度。所有桌面浏览器都忽略视口,所有div都是相等的和窗口的宽度。这是正确的。
Android的浏览器(standart和mobile )将窗口的宽度设置为1300 to,所有div的宽度设置为1300 to,而不管方向如何。这是正确的。
问题在于我的ipod和我朋友的iphone。顶部div为1300 is,而底部div(有固定位置)为1280 is。这种情况只发生在人像定向上。在景观方向上,所有divs都是正常的(1300 In )。为什么在景观模式下固定div的宽度是1280 in?这真的是狩猎中的窃听器吗?还是我漏掉了什么?
测试页代码:
<!doctype html>
<html>
<head>
<meta content="width=1300" name="viewport" />
<title>Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type=text/javascript>
function updateInfo()
{
$("div.test").each(function()
{
var t = $(this);
var w = t.width();
t.find("span").html("width = "+w);
});
}
$(function(){setInterval(updateInfo,100);});
</script>
</head>
<body>
<div class="test t1">100% width relative <span></span></div>
<div class="test t2">100% width absolute <span></span></div>
<div class="test t3">100% width fixed bottom <span></span></div>
<style>
*
{
padding:0;
margin:0;
}
body{min-width:1300px;}
div{width:100%;}
div.t1{background:lime;}
div.t2{position:absolute;background:blue;}
div.t3{position:fixed;bottom:0;background:red;}
</style>
</body>
</html>发布于 2015-04-04 11:43:24
问题是规模最小。默认值为0.25,设备宽度为320,视图宽度的最大值为1280 my。在元中设置适当的最小比例尺有帮助。
https://stackoverflow.com/questions/29440080
复制相似问题