导航菜单打开时,使内容不透明

时间:2016-01-26 16:34:05

标签: html css opacity

当我打开导航栏时,我想在内容上显示半透明蒙版。

这是我的代码:

<nav class="navbar navbar-default">
  <div class="collapse navbar-collapse"">
    <ul class="nav navbar-nav">
        <li><a href="/Home">Home</a></li>
        <li class="dropdown">
            <a href="/about" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About</a>
            <ul class="dropdown-menu">
                <li><a href="/about/what">What</a></li>
                <li><a href="/about/how">How</a></li>
            </ul>
         </li>
      </ul>
  </div>
 </nav>

 <div class= "content">
    <div class = "container">
      <div class = "row">
        <div class="col-sm-10">
            Enter Text Here
        </div>
    </div>
</div>

有没有办法只使用css?

1 个答案:

答案 0 :(得分:0)

如果将类添加到活动导航项中,那么类似于兄弟选择器吗?

nav.active + .content {
display: block;
width: 100%;
height: 100%;
content: " ";
position: absolute;
background: rgba(0,0,0,0.6);
left: 0;
top: 0;
z-index: 999;

}