CSS 在 Bootstrap 3 导航栏上方放置横幅?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27209336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:48:06  来源:igfitidea点击:

Placing banner above the Bootstrap 3 navbar?

csstwitter-bootstrap-3navbarbanner

提问by Chaka

I have this Bootstrap 3 navbar: http://www.bootply.com/xkcDjvQslb

我有这个 Bootstrap 3 导航栏:http: //www.bootply.com/xkcDjvQslb

I want the following modifications:

我想要以下修改:

  1. Add banner above the fixed navbar
  2. Hide the banner when I scroll down
  1. 在固定导航栏上方添加横幅
  2. 向下滚动时隐藏横幅

I saw the following example: http://www.bootply.com/69848; not great at bootstrap and when I pull the relevant code it breaks my menu.

我看到了下面的例子:http: //www.bootply.com/69848;不擅长引导,当我提取相关代码时,它会破坏我的菜单。

The banner (above the navbar) would be a table with a logo on the left side and title on the right. I need someone to point me in the right direction?

横幅(导航栏上方)将是一张表格,左侧有徽标,右侧有标题。我需要有人为我指明正确的方向吗?

采纳答案by Chaka

I found the solution here: http://jsfiddle.net/DTcHh/541/, just needed to clean up my code:

我在这里找到了解决方案:http: //jsfiddle.net/DTcHh/541/,只需要清理我的代码:

topnavbar {
    margin: 0;
}
#topnavbar.affix {
    position: fixed;
    top: 0;
    width: 100%;
}

#banner {
     background-color: yellow;   
}

回答by Rafael

Remove navbar-fixed class in nav. Then place markup above the nav.

删除导航中的导航栏固定类。然后在导航上方放置标记。

http://www.bootply.com/vxJEiv1RC2

http://www.bootply.com/vxJEiv1RC2