Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.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 修正了引导中的导航条_Html_Css_Twitter Bootstrap - Fatal编程技术网

Html 修正了引导中的导航条

Html 修正了引导中的导航条,html,css,twitter-bootstrap,Html,Css,Twitter Bootstrap,我使用属性navbar fixed top将我的navbar固定到顶部。但我还有一个我们看不到的固定元素 这是我的固定导航栏,下面是我想看到的固定元素 现在发生的是,我的元素(只称为“线”)是由选项固定的,但导航栏的位置不是绝对的,因此线通过导航栏,当我向下滚动时,线是固定的,但它被导航栏隐藏。我不知道它是否清晰,但我希望这两个元素是粘合的,而不是重叠的 我该怎么办 编辑: 我的朋友: 如果您尝试删除th enavbar,您将看到第一行保留在页面顶部。使用导航栏,它是隐藏的。我已经编写了脚本来

我使用属性
navbar fixed top
将我的navbar固定到顶部。但我还有一个我们看不到的固定元素

这是我的固定导航栏,下面是我想看到的固定元素

现在发生的是,我的元素(只称为“线”)是由选项固定的,但导航栏的位置不是绝对的,因此线通过导航栏,当我向下滚动时,线是固定的,但它被导航栏隐藏。我不知道它是否清晰,但我希望这两个元素是粘合的,而不是重叠的

我该怎么办

编辑:

我的朋友:


如果您尝试删除th enavbar,您将看到第一行保留在页面顶部。使用导航栏,它是隐藏的。

我已经编写了脚本来修复此问题,请将此添加到代码中:

js

css

演示:

请与我们共享您的代码(更好的JFiddle或Plunker),这样我们就可以看到您目前正在做什么。您的“行”需要在顶部留出更多的空间,因为您使用top:0px;你需要像top:100px;并将其调整到引导导航栏的高度;)@汉姆斯特我试过了,但它只是在导航栏和线路之间做了一个边缘。当我滚动时,行仍然被导航栏隐藏。请Lison,你能创建一个小提琴(例如:bootply.com)来重现你的问题吗?它将更快地帮助您,而不是猜测图片上有什么…@YenneInfo我正在尝试创建一个,但我有一些困难来做它^”
var navheight = $(".navbar-fixed-top").innerHeight();
var offtop = $(".ht_clone_top").offset().top;
$(window).scroll(function(){
    var scrolltop = $(window).scrollTop();
    if(scrolltop + navheight >= offtop){
        if(!($(".ht_clone_top").hasClass("affixed"))){
            $(".ht_clone_top").addClass("affixed");
        }
        if(offtop>= scrolltop){
            console.log("now");
            $(".ht_clone_top").css({
                "top": scrolltop - 40
            });
        } else {
            $(".ht_clone_top").css({
                "top": 50
            });
        }
    } else {
        $(".ht_clone_top").removeClass("affixed");
        $(".ht_clone_top").css({
            "top": 0
        });
    }
});
.affixed {
    z-index: 99999;
    position: absolute;
}