如何在页面顶部保留菜单栏?

时间:2017-08-11 06:41:48

标签: html css html5 drop-down-menu menubar

我正在努力让我的菜单栏保持在页面顶部,如https://forbes.com为我的bootcamp项目&团队登陆页面。

我不知道该怎么做:https://github.com/JonDevOps/W3Develops-new-landing-page

我希望它保持在页面顶部,即使我向下滚动。

2 个答案:

答案 0 :(得分:2)

使用固定位置:

.menubar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: {your height}
}

答案 1 :(得分:0)

尝试使用以下代码。

.menubar {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 999;
}