css - 在与主要内容关联的导航栏中添加背景

标签 css twitter-bootstrap

如何将背景图片关联到我的导航栏?我尽力去联想它,但我失败了。您有任何教程或技巧吗?

Here's my index

<nav class="navbar navbar-default navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>                        
          </button>
        </div>
        <div class="collapse navbar-collapse" id="myNavbar">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
            <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
          </ul>
        </div>
      </div>
    </nav><!--End of navbar-->

    <!-- start of picture div-->
    <div id="bgp">

              <h1 id="top-header">

              </h1>  

    </div>

Here's my CSS:

#bgp
{
background-image: url("images/city.png");
opacity: 0.8;
width: 100%;
height: 100rem;
background-size: 100%,500%;
background-repeat: no-repeat;
}

最佳答案

好的,开始吧:https://jsfiddle.net/d7uamo66/

基本上标题没有图像但是是透明的。 如果您向下滚动标题透明度变为白色。

关于css - 在与主要内容关联的导航栏中添加背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31021406/

相关文章:

html - 使用css的div矩阵结构

javascript - CSS `Position: Fixed` 不在滚动条上移动

html - 父子元素的css定位

c# - 编译 LESS,压缩 CSS 和 JS 并输出到构建目录

twitter-bootstrap - bootstrap 3 网格布局在 IE8 中不起作用

html - 谷歌地图的自定义搜索框

jquery - <th> 边框在 IE 中不起作用

javascript - CSS父/子问题

jquery - 推特 Bootstrap : how to add x on the right for clearing inside input box when user is typing?

jquery - 单击菜单项时防止下拉菜单关闭