引导固定导航栏内div [英] Bootstrap fixed navbar inside div

查看:163
本文介绍了引导固定导航栏内div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bootstrap文档中,他们可以陷阱一个在它们的 .bs-docs-example div中:

In bootstrap documentation they're able to "trap" a .navbar-fixed-top inside their .bs-docs-example div:

<div class="bs-docs-example bs-navbar-top-example">
    <div class="navbar navbar-fixed-top" style="position: absolute;">
        <div class="navbar-inner">
        [...]

但是,如果我在测试页面中执行相同的操作, 逃脱div并固定在身体顶部,而不是顶部。它是如何实现的?

But if I do the same in my test page the navbar "escapes" the div and get fixed in the top of the body, not the top of the div. How it's the trick achieved?

推荐答案

好了解了它。父元素容器必须包含 position:relative ,并且navbar必须具有 position:absolute ,这样,如果您连接 .navbar-fixed-top .navbar-fixed-bottom 它将相对于父元素得到固定,而NOT相对于整个页面。是的!

Ok figured it out. The parent element container must have position: relative, and navbar must have position: absolute, that way if you attach either .navbar-fixed-top or .navbar-fixed-bottom it will get fixed relative to the parent element and NOT relative to the entire page. Yeah!

这篇关于引导固定导航栏内div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆