Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html FixedHeader和fixed菜单栏_Html_Css - Fatal编程技术网

Html FixedHeader和fixed菜单栏

Html FixedHeader和fixed菜单栏,html,css,Html,Css,我已经修补这个太久了,所以我在这里提出了问题。我正在尝试在网页顶部设置一个菜单栏。我的方法的问题是,内容页面被滚动到菜单栏的“后面”,这会给用户带来问题。它不会在菜单上停止表格的标题,而是滚动到菜单并锁定在屏幕顶部 css看起来像这样 #header { width:100%; height:50px; position: fixed; top:0; background-color:rgba(255,0,0,0.5); } #content {

我已经修补这个太久了,所以我在这里提出了问题。我正在尝试在网页顶部设置一个菜单栏。我的方法的问题是,内容页面被滚动到菜单栏的“后面”,这会给用户带来问题。它不会在菜单上停止表格的标题,而是滚动到菜单并锁定在屏幕顶部

css看起来像这样

#header {
    width:100%;
    height:50px;
    position: fixed;
    top:0;
    background-color:rgba(255,0,0,0.5);
}


#content {
    background-color:rgba(0,0,255,0.5);
    position: static;
    margin-top: 50px;
}

我能做些什么来阻止表格一直向上滚动,阻止标题停在菜单下方?

我想您可以在DataTable/FixedHeader的文档中找到答案。正如您在这里看到的,您可以:

offsetTop指定从窗口顶部的偏移量,固定标题在滚动时将锁定到该窗口顶部。这对我们来说很有用 使用页面顶部的固定元素—例如 Twitter引导修复菜单

offsetTop
更改为菜单栏的高度(50),您应该已经全部设置好了

此外,您还可以在
#标题
中添加一个大的
z索引
,以确保它位于其他元素的“顶部”

#header {
    z-index: 9999;
    /* And your other properties here */
}

移除
位置:固定或更改
top:0
。?属性是“页边距顶部”,而不是“页边距顶部”,您也可以尝试“padding top”,然后查看是否helps@arieljuod:很好的捕获,但这没有做到。@PopLa面:如果我这样做,菜单将不再是静态的并滚动。你能发布一个JSFIDLE以便我们可以使用实际的代码吗?有趣。出于某种原因,这对我不起作用。这个描述中的演示似乎也不起作用。没关系。它起作用了。不确定最初出了什么问题。谢谢你的帮助。
#header {
    z-index: 9999;
    /* And your other properties here */
}