我正在使用 Bootstrap 提供的固定导航栏的示例代码。有什么相对简单的方法可以使浏览器滚动条不与固定导航栏重叠。
示例如下:
这是我想要得到的:
非常感谢。 问候。
最佳答案
为此,您需要将标题设为页面顶部的固定元素,并使用 position: fixed
容器来包装页面上的其余内容.这是一个例子:
CSS:
html, body {
width: 100%;
height: 100%;
}
#header {
position: fixed;
width: 100%;
height: 50px;
top: 0;
}
#container {
width: 100%;
position: fixed;
top: 50px;
bottom: 0;
overflow: auto;
}
HTML:
<body>
<div id="header">
<ul><!-- other header elements --></ul>
</div>
<div id="container">
<!-- All of the content of your site -->
</div>
</body>
关于html - Bootstrap 。使垂直浏览器滚动条在固定导航栏下开始。 (不重叠),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29017536/