Wednesday, March 2, 2016

Bootstrap 3 Carousel Fade Effect


Fostrap - Create a slide show is a tough job for the new learn CSS because it essentially Slide Show made with Javascript. For me, Javascript is a programming language that is a bit complicated, so for creating action such as the slide show is also difficult.

But after I learned Bootstrap makes a slide show is a very easy job.

And now, Fostrap will be giving a Tutorial to make a carousel bootstrap by adding more wonderful effect fadein & out



Lets Make Bootstrap Carousel Effect FadeIn and FadeOut

1. Copy The HTML Below


<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</link>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css"/>
</link>
<div class="carousel slide carousel-fade" data-ride="carousel" id="carouselFade">
<!--
Wrapper for slides
-->
<br />
<div class="carousel-inner" role="listbox">
<div class="item active">
    <div class="carousel-caption">
        <h3>
            First slide label
        </h3>
        Praesent commodo cursus magna, vel scelerisque nisl consectetur.
    </div>
</div>
<div class="item">
    <div class="carousel-caption">
        <h3>
            Second slide label
        </h3>
        Praesent commodo cursus magna, vel scelerisque nisl consectetur.
    </div>
</div>
<div class="item">
    <div class="carousel-caption">
        <h3>
            Third slide label
        </h3>
        Praesent commodo cursus magna, vel scelerisque nisl consectetur.
    </div>
</div>
</div>
<!--
Controls
-->
<a class="left carousel-control" data-slide="prev" href="https://www.blogger.com/blogger.g?blogID=8927574837029310736#carouselFade" role="button">
<span aria-hidden="true" class="glyphicon glyphicon-chevron-left">
</span>
<span class="sr-only">
    Previous
</span>
</a>
<a class="right carousel-control" data-slide="next" href="https://www.blogger.com/blogger.g?blogID=8927574837029310736#carouselFade" role="button">
<span aria-hidden="true" class="glyphicon glyphicon-chevron-right">
</span>
<span class="sr-only">
    Next
</span>
</a>
</div>
<!--
jQuery (necessary for Bootstrap's JavaScript plugins)
-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<!--
Include all compiled plugins (below), or include individual files as needed
-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js">
</script>

2. Copy The CSS Below

   

.carousel-fade .carousel-inner .item {
opacity: 0;
transition-property: opacity;
}
.carousel-fade .carousel-inner .active {
opacity: 1;
}
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
left: 0;
opacity: 0;
z-index: 1;
}
.carousel-fade .carousel-inner .next.left,
.carousel-fade .carousel-inner .prev.right {
opacity: 1;
}
.carousel-fade .carousel-control {
z-index: 2;
}
@media all and (transform-3d), (-webkit-transform-3d) {
.carousel-fade .carousel-inner > .item.next,
.carousel-fade .carousel-inner > .item.active.right {
opacity: 0;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.carousel-fade .carousel-inner > .item.prev,
.carousel-fade .carousel-inner > .item.active.left {
opacity: 0;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.carousel-fade .carousel-inner > .item.next.left,
.carousel-fade .carousel-inner > .item.prev.right,
.carousel-fade .carousel-inner > .item.active {
opacity: 1;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
.carousel-caption {
text-shadow: 0 1px 4px rgba(0,0,0,.9);
font-size:17px
}
.carousel-caption h3 {
font-size: 30px;
font-family: 'Lato', sans-serif;
}
html,
body,
.carousel,
.carousel-inner,
.carousel-inner .item {
height: 100%;
}
.item:nth-child(1) {
background: url('https://snap-photos.s3.amazonaws.com/img-thumbs/960w/HZZKGVVJ6I.jpg');
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
.item:nth-child(2) {
background: url('https://snap-photos.s3.amazonaws.com/img-thumbs/960w/D2ROMCUEIV.jpg');
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
.item:nth-child(3) {
background: url('https://snap-photos.s3.amazonaws.com/img-thumbs/960w/PU9HHZB5QW.jpg');
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}

3. Copy The Javascript Below

   

$('#carouselFade').carousel();



Note
: If you want to change the background, just edit The CSS, edit in :

.item:nth-child(1) {
background: url('-----------Your Background Image-----------');
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
.item:nth-child(2) {
background: url('-----------Your Background Image-----------');
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
.item:nth-child(3) {
background: url('-----------Your Background Image-----------');
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}

1 komentar so far

Please, explain where to place the codes for non expert users!
I don't understand where to insert the codes in my layout.


EmoticonEmoticon