html - How to display previous and next images with a Bootstrap carousel -
the effect i'm looking can seen in following image, carousel 3 images.
how can make bootstrap carousel show left , right images opacity of 0.7?
the following carousel template.
<div class="col-md-10 center-block"> <img id="logo" src="./img/yoox_group.png" alt="yoog group" /> <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> <!-- indicators --> <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> <!-- wrapper slides --> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="./img/carousel/carousel-001.jpg" alt="..." /> <div class="carousel-caption"> </div> </div> <div class="item"> <img src="./img/carousel/carousel-002.jpg" alt="..." /> <div class="carousel-caption"> </div> </div> <div class="item"> <img src="./img/carousel/carousel-003.jpg" alt="..." /> <div class="carousel-caption"> </div> </div> </div> <!-- controls --> <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> <img id="arrowleft" src="./img/arrow_left.png" /> <span class="sr-only">previous</span> </a> <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> <img id="arrowright" src="./img/arrow_right.png" /> <span class="sr-only">next</span> </a> </div> </div>
#arrowleft { background-color: #fff; padding: 10px 8px; position: absolute; margin-left: -95px; top: 45%; z-index: 5; display: inline-block; } #arrowright { background-color: #fff; padding: 10px 8px; position: absolute; margin-left: 67px; top: 45%; z-index: 5; display: inline-block; }
expanding on this answer question, if add following css code provide effect you're looking for.
we have expand .carousel-inner
larger .carousel
, center , hide overflow of .carousel
.
to obtain opacity effect, expand size of previous , next arrow containers, set translucent white background.
bootstrap >= 3.3.0
in bootstrap version 3.3.0 there change in css invalidated previous method. current method.
(demo)
.carousel { overflow: hidden; } .carousel-inner { width: 150%; left: -25%; } .carousel-inner > .item.next, .carousel-inner > .item.active.right { -webkit-transform: translate3d(33%, 0, 0); transform: translate3d(33%, 0, 0); } .carousel-inner > .item.prev, .carousel-inner > .item.active.left { -webkit-transform: translate3d(-33%, 0, 0); transform: translate3d(-33%, 0, 0); } .carousel-control.left, .carousel-control.right { background: rgba(255, 255, 255, 0.3); width: 25%; }
bootstrap < 3.3.0
(demo)
.carousel { overflow: hidden; } .carousel-inner { width: 150%; left: -25%; } .carousel-inner .active.left { left: -33%; } .carousel-inner .next { left: 33%; } .carousel-inner .prev { left: -33%; } .carousel-control.left, .carousel-control.right { background: rgba(255, 255, 255, 0.3); width: 25%; }
Comments
Post a Comment