Bootstrap v4.0.3 Alpha Carousel Shadow

时间:2016-09-04 13:59:46

标签: html css twitter-bootstrap twitter-bootstrap-4 bootstrap-4

阿罗哈,

我正在(仍然)在自举网站上工作,并希望在旋转木马上应用(插入!)阴影。 HTML看起来像这样:

    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
    <li data-target="#carousel-example-generic" data-slide-to="1"></li>
    <li data-target="#carousel-example-generic" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner" role="listbox">
    <div class="carousel-item active">
      <img src="..." alt="First slide">
    </div>
    <div class="carousel-item">
      <img src="..." alt="Second slide">
    </div>
    <div class="carousel-item">
      <img src="..." alt="Third slide">
    </div>
  </div>
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="icon-prev" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="icon-next" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

试图通过

申请
.carousel-item {
    box-shadow: inset 0 0 20rem rgba(0,0,0,1);

}
.carousel-item img {
    z-index: -1;
}

(和其他一些不起作用的人)。

有人知道如何解决这个问题吗?

2 个答案:

答案 0 :(得分:3)

图像隐藏了阴影。请使用带有box-shadow的伪元素..

.carousel-item:before {
    -webkit-box-shadow: inset 0 0 20rem rgba(0, 0, 0, 1);
    box-shadow: inset 0 0 20rem rgba(0, 0, 0, 1);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    content: "";
}

Codeply Demo

答案 1 :(得分:1)

我认为插入阴影在这里,但没有可见,然后图片填满容器。

试试这个:

.carousel-item{
    padding: 20rem
    box-shadow: inset 0 0 20rem rgba(0,0,0,1);
}

或阅读:http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_carousel2&stacked=h