如何将页面固定在中心(示例:vk.com)。 在此站点上,如果显示/隐藏滚动条 - 容器位置不会向左/向右移动。
我有两个容器:
<header class="topPage" style="width:100%;height:50px;position:fixed;top:0;left:0;">
<div class="wrap" style="margin:0 auto;width:860px;">
</div>
</header>
和
<section class="centerPage" style="width:100%;position:relative;padding-top:50px; display:inline-block">
<div class="wrap" style="margin:0 auto;width:860px;">
</div>
</section>
如果滚动条显示/隐藏,我需要修复所有容器。谢谢。
最佳答案
首先,为 Container Div 指定 width
。
其次,给 margin-left:auto; margin-right:auto;position:fixed;
用于容器 div。
那行得通。
关于jquery - 防止内容在滚动条显示/隐藏上水平移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25010803/