如何使导航栏始终位于顶部?

时间:2012-11-14 00:19:38

标签: html css zurb-foundation

我正在Foundation使用ZURB并尝试将导航栏设置到顶部。

6 个答案:

答案 0 :(得分:11)

我不知道这两件事是什么,但这就是你如何修复某些东西而不管CSS的窗口滚动位置:

#navbar {
    position: fixed;
    top: 0px;
    width: 100%;
}​

见这里:http://jsfiddle.net/qC2Dt/

答案 1 :(得分:8)

如果您使用的是基础,可以使用:

<nav class="top-bar fixed"></nav>

答案 2 :(得分:2)

使用风格:

position:fixed;
top:0px;

答案 3 :(得分:2)

加入Alex Wayne的回答:

我发现有必要添加一个足够高的 z-index ,以使导航栏始终显示在其他元素之上。

#navbar {
   z-index: 10000;
   position: fixed;
   top: 0px;
   width: 100%;
}​

答案 4 :(得分:1)

您也可以使用bootstrap设计的类。

  <nav class="navbar-fixed-top">

答案 5 :(得分:1)

首先,导入ActivatedRoute:

import { ActivatedRoute } from "@angular/router";

然后在构造函数中可以提取参数。例如:

constructor(private route: ActivatedRoute) { 
    this.route.queryParams.subscribe(params => {
        let myparam = params['myparam'];
        console.log(myparam); // Print the parameter to the console.  
    });
}

有关信息,请参见https://www.mackenziesoftware.com/2020/06/how-to-get-param-from-url-in-angular.html

相关问题