简体   繁体   English

如何更改twitter-bootstrap导航栏的框阴影?

[英]How to change the box-shadow of twitter-bootstrap navbar?

I'm using twitter-bootstrap, and I have the following code to generate a navbar with box-shadow, based in this post : 我正在使用twitter-bootstrap,基于此帖子 ,我具有以下代码来生成带有阴影框的导航栏:

Here is a working fiddle with the effect1: http://jsfiddle.net/X4drb/15/ 这是关于effect1的有效提琴: http : //jsfiddle.net/X4drb/15/

But if I try to use the effect2 instead, does not displayed the shadow: http://jsfiddle.net/X4drb/16/ 但是,如果我尝试使用effect2,则不会显示阴影: http : //jsfiddle.net/X4drb/16/

CSS CSS

/*==================================================
 * Effect 1
 * ===============================================*/
.effect1{
    -webkit-box-shadow: 0 10px 6px -6px #777;
       -moz-box-shadow: 0 10px 6px -6px #777;
            box-shadow: 0 10px 6px -6px #777;
}

/*==================================================
 * Effect 2
 * ===============================================*/
.effect2
{
  position: relative;
}
.effect2:before, .effect2:after
{
  z-index: -1;
  position: absolute;
  content: "";
  bottom: 15px;
  left: 10px;
  width: 50%;
  top: 80%;
  max-width:300px;
  background: #777;
  -webkit-box-shadow: 0 15px 10px #777;
  -moz-box-shadow: 0 15px 10px #777;
  box-shadow: 0 15px 10px #777;
  -webkit-transform: rotate(-3deg);
  -moz-transform: rotate(-3deg);
  -o-transform: rotate(-3deg);
  -ms-transform: rotate(-3deg);
  transform: rotate(-3deg);
}
.effect2:after
{
  -webkit-transform: rotate(3deg);
  -moz-transform: rotate(3deg);
  -o-transform: rotate(3deg);
  -ms-transform: rotate(3deg);
  transform: rotate(3deg);
  right: 10px;
  left: auto;
}

HTML HTML

<nav class="navbar navbar-default effect1">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">  <i class="fa fa-bars"></i>
            </button> <a class="navbar-brand" href="index.html"><img src="http://placehold.it/30x30&text=logo" ></a>

        </div>
        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">Hello</a>
                </li>
                <li><a href="#">Stack</a>
                </li>
                <li><a href="#">Overflow</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

Why the first effect works perfectly, and the second one doesnt? 为什么第一个效果完美,而第二个效果不完美? What am I missing? 我想念什么? Do you have any idea to do it? 你有什么想法吗?

Size is very small menu to display shadows. 尺寸很小的菜单显示阴影。 In the style you need to change the value on the bottom until you see the shadow and add display:block for .effect2:before, .effect2:after 在样式中,您需要更改bottom的值,直到看到阴影并为.effect2:before, .effect2:after添加display:block

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM