gpt4 book ai didi

javascript - 如何让页面内容始终出现在导航栏下方?

转载 作者:太空宇宙 更新时间:2023-11-03 20:52:30 24 4
gpt4 key购买 nike

我想让我的页面内容始终显示在导航栏下方,类似于此页面的工作方式:

http://www.google.com/intl/en/enterprise/apps/business/products.html#calendar

您可以向下或向上滚动内容,但导航栏永远不会消失。

为此,我使用了 position:fixed将导航栏固定到页面顶部。这行得通,但当我希望内容始终被推到导航栏下方时,我仍然能够上下滚动内容,使其“穿过”导航栏并越过导航栏。

关于如何做到这一点有什么想法吗?这是我的 <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;
}

这是 <div id="container"> 的 css出现在 #navigation 下面并包含所有页面内容主体:

#container
{
position: absolute;
margin-top: 180px;
font-size: 25px;
width: 90%;
}

最佳答案

它通过的原因是因为您没有为导航栏设置背景颜色。试试看。

编辑:查看了您的源代码。将 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;
}

问题是 z-index。将其置于 999 会将导航栏置于所有其他元素之上。

关于javascript - 如何让页面内容始终出现在导航栏下方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14405276/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com