[英]How to always make page content appear beneath navigation bar?
I want to keep the content of my page to always appear beneath the navigation bar, similar to how this page works: 我想让页面内容始终显示在导航栏下方,类似于此页面的工作方式:
http://www.google.com/intl/en/enterprise/apps/business/products.html#calendar http://www.google.com/intl/en/enterprise/apps/business/products.html#calendar
You can scroll down or up in the content, but the navigation bar never goes away. 您可以在内容中向下或向上滚动,但是导航栏永远不会消失。
For this purpose, I've used position:fixed
to fix the navigation bar to the top of the page. 为此,我使用position:fixed
将导航栏position:fixed
在页面顶部。 This works, but I'm still able to scroll the content up and down, causing it to run 'through' and over the navigation bar, when I want the content to always be pushed below the navigation bar. 这可行,但是当我希望始终将内容推到导航栏下方时,我仍然可以上下滚动内容,使其在导航栏中“遍历”。
Any ideas on how to do this? 有关如何执行此操作的任何想法? Here's my css code for the <ul id='navigation'>
containing the navigation: 这是我的<ul id='navigation'>
的CSS代码,其中包含导航:
#navigation
{
text-align: center;
position: fixed;
float: left;
margin: 0;
padding: 0;
top: 0;
left: 0;
list-style-type: none;
}
#navigation li
{
display: inline-block;
width: 150px;
height: 110px;
cursor: pointer;
}
And here's the css for the <div id="container">
which appears below #navigation
and holds all of the page content body: 这是<div id="container">
的css,它显示在#navigation
下面,并包含所有页面内容主体:
#container
{
position: absolute;
margin-top: 180px;
font-size: 25px;
width: 90%;
}
The reason it's going through is because you didn't set a background color to your navigation bar. 遇到这种情况的原因是,您没有为导航栏设置背景色。 Try that. 试试看
Edit: Looked at your source code. 编辑:查看您的源代码。 Replace navigation CSS in style.css file with this: 以此替换style.css文件中的导航CSS:
#navigation
{
text-align: center;
position: fixed;
float: left;
margin: 0;
padding: 0;
top: 0;
left: 0;
list-style-type: none;
background-color: #FFFFFF;
z-index:999;
}
The problem was the z-index. 问题是z-index。 Putting it at 999 puts the navigation bar on top of all other elements. 将其置于999会将导航栏置于所有其他元素的顶部。
您可以使用属性z-index:xxx,您尝试过吗?
Years ago created my site with that same functionality. 多年前,我使用相同的功能创建了我的网站。 I opted for Server Side Includes and it works great. 我选择了服务器端包含,效果很好。 I created a 'header' the navigation links and a 'footer' that gets included on each page. 我创建了一个“页眉”导航链接和一个“页脚”,每个页面都包含了该页脚。
您是否尝试添加data-role="header"
?
<div data-role="header" data-position="fixed">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.