jquery - 防止内容在滚动条显示/隐藏上水平移动

标签 jquery css

如何将页面固定在中心(示例: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/

相关文章:

html - 如何在单独的 div 中水平对齐按钮

javascript - 一次具有相同形式的多个按钮

javascript - 来自变量的 jQuery 选择器

javascript - jQuery,通过href选择时转义字符

jquery - 如何在 jQuery 中恢复点击事件

javascript - 在移动浏览器或 PhoneGap 应用程序之间检测

javascript - jQuery 发起的 CSS 转换在重复触发时出现故障

javascript - Firefox 和 Chrome/IE 中的 jQuery animate() 不同

jquery - Bootstrap Collapse 复杂行为

css - 我如何使用 Sass 给某些东西一个默认但可选的可覆盖值?