【发布时间】:2013-12-12 22:59:24
【问题描述】:
谁能告诉我为什么 position:fixed 会导致元素比浏览器或页面上的其他内容更宽并导致水平滚动?
这里是代码 HTML
<header>
this is a header
</header>
<div class="container">
this is a container
</div>
CSS
header {
width: 90%;
height: 100px;
background: blue;
position: fixed;
z-index: 100;
}
.container {
width: 90%;
height: 500px;
background: red;
position: relative;
z-index: -2;
}
这里是codepen的链接http://codepen.io/colbydodson/pen/wcgua
【问题讨论】:
-
这篇博文 (bradfrost.com/blog/mobile/fixed-position) 虽然陈旧且没有直接解决您的问题,但对于其他在移动设备上存在固定定位问题的人来说可能值得一看。