Carousel Bootstrap 4 - css

background-image: linear-gradient(to top, black 0%, transparent 100%);
How to add this gradient to bootstrap 4 carousel?
I tried to put it in carousel-item and carousel-inner. No affect.
This is how looks my bs4 carousel
<div id="gallery" class="carousel slide" data-ride="carousel" style="margin-top: 6rem;">
<ol class="carousel-indicators">
<li data-target="#gallery" data-slide-to="0" class="active"></li>
<li data-target="#gallery" data-slide-to="1"></li>
<li data-target="#gallery" data-slide-to="2"></li>
<li data-target="#gallery" data-slide-to="3"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/gallery1.jpg" class="d-block w-100 gallery-img" alt="ВИГВАМ">
<div class="carousel-caption">
<h5>item0</h5>
<p>desc</p>
</div>
</div>
<div class="carousel-item">
<img src="img/gallery8.jpg" class="d-block w-100 gallery-img" alt="item">
<div class="carousel-caption">
<h5>item1</h5>
<p>desc</p>
</div>
</div>
<div class="carousel-item">
<img src="img/gallery2.jpg" class="d-block w-100 gallery-img" alt="item">
<div class="carousel-caption">
<h5>item2</h5>
<p>desc</p>
</div>
</div>
<div class="carousel-item">
<img src="img/gallery3.jpg" class="d-block w-100 gallery-img" alt="item">
<div class="carousel-caption">
<h5>item3</h5>
<p>desc</p>
</div>
</div>
<a class="carousel-control-prev" href="#gallery" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">prev</span>
</a>
<a class="carousel-control-next" href="#gallery" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">next</span>
</a>
</div>
</div>

.carousel::after {
background-image: linear-gradient(to top, black 0%, transparent 100%);
bottom: 0;
content: "";
height: 100px;
left: 0;
position: absolute;
right: 0;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div id="gallery" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#gallery" data-slide-to="0" class="active"></li>
<li data-target="#gallery" data-slide-to="1"></li>
<li data-target="#gallery" data-slide-to="2"></li>
<li data-target="#gallery" data-slide-to="3"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://www.chancerides.com/wp-content/uploads/2017/03/cr_detail_36ft_carrousel.jpg" class="d-block w-100 gallery-img" alt="ВИГВАМ">
<div class="carousel-caption">
<h5>item0</h5>
<p>desc</p>
</div>
</div>
<div class="carousel-item">
<img src="https://www.chancerides.com/wp-content/uploads/2017/03/cr_detail_36ftdd_carrousel.jpg" class="d-block w-100 gallery-img" alt="item">
<div class="carousel-caption">
<h5>item1</h5>
<p>desc</p>
</div>
</div>
<div class="carousel-item">
<img src="https://www.guernseys.com/v2/images/Carousel/700x400_1.jpg" class="d-block w-100 gallery-img" alt="item">
<div class="carousel-caption">
<h5>item2</h5>
<p>desc</p>
</div>
</div>
<div class="carousel-item">
<img src="https://www.chancerides.com/wp-content/uploads/2017/09/carrousel_gallery_2.jpg" class="d-block w-100 gallery-img" alt="item">
<div class="carousel-caption">
<h5>item3</h5>
<p>desc</p>
</div>
</div>
<a class="carousel-control-prev" href="#gallery" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">prev</span>
</a>
<a class="carousel-control-next" href="#gallery" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">next</span>
</a>
</div>
</div>

Related

Modify the height of Bootstrap Carousel control?

The blue section of the following image shows the triggering area of the bootstrap carousel. I took the screenshot from the bootstrap doc.
I would like to modify the height of the triggering region (e.g. From 100% of the carousel height to 50%). May I know how can I modify it?
Thanks in advance
To solve this, just modify the properties of .carousel-control-prev and .carousel-control-prev in the CSS.
.carousel-control-prev,
.carousel-control-next {
height: 25%;
top: 37.5%;
};
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
<body>
<div class="container">
<div class="row">
<div class="col">
<div id="carouselExampleIndicators" class="carousel slide my-4" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block img-fluid" src="http://placehold.it/900x350" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="http://placehold.it/900x350" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="http://placehold.it/900x350" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
</body>
I have no idea why the top property could not override in the demo. But it works in my project.

Issues with Bootstrap Carousel (image shows but doesn't slide/change)

I'll preface this by saying I really don't have much experience in this, but I've looked through documentations and solutions that helped others and I've yet to fix my issue so I'll go ahead and make my own post.
<div id="randomCarousel" class="carousel slide" data-ride="carousel">
<!--Indicator Buttons-->
<ol class="carousel-indicators">
<li data-target="#randomCarousel" data-slide-to="0" class="active"></li>
<li data-target="#randomCarousel" data-slide-to="1"></li>
<li data-target="#randomCarousel" data-slide-to="2"></li>
</ol>
<!--Carousel w/Images-->
<div class="container">
<div class="carousel-inner">
<!--ALL PICS ARE PART OF CREATIVE COMMONS; ADDED SIMPLY FOR FUN-->
<div class="carousel-item active">
<img src="https://images.pexels.com/photos/459225/pexels-photo-459225.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="d-block w-100" alt="First">
</div>
<div class="carousel-item">
<img src="https://images.pexels.com/photos/2283759/pexels-photo-2283759.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="d-block w-100" alt="Second">
</div>
<div class="carousel-item">
<img src="https://images.pexels.com/photos/2283759/pexels-photo-2283759.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="d-block w-100" alt="Third">
</div>
</div>
</div>
<!--Next and Previous buttons-->
<a class="carousel-control-prev" href="#randomCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#randomCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
I've gone ahead and added scripts and links found on the bootstrap website also but to no avail. Any additional feedback would also be greatly appreciated.
I'm not sure what is the issue with your code, But when i customize my code then it will worked. Please review my code and let me know further clarification.
Hope it will help
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<div id="carousel-indicators" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-indicators" data-slide-to="0" class="active"></li>
<li data-target="#carousel-indicators" data-slide-to="1"></li>
<li data-target="#carousel-indicators" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="container">
<div class="carousel-inner">
<div class="item active">
<img src="https://images.pexels.com/photos/459225/pexels-photo-459225.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="d-block w-100" alt="First">
</div>
<div class="item">
<img src="https://images.pexels.com/photos/2283759/pexels-photo-2283759.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="d-block w-100" alt="Second">
</div>
<div class="item">
<img src="https://images.pexels.com/photos/2283759/pexels-photo-2283759.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="d-block w-100" alt="Third">
</div>
</div>
</div>
</div>
<!--Next and Previous buttons-->
<a class="carousel-control-prev" href="#randomCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#randomCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Your code is working fine, may be you forgot to include bootstrap library files (CSS and JS) or may be forgot to include js library file. Not sure exactly what you are missing.
Here is the working example of your code.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div id="randomCarousel" class="carousel slide" data-ride="carousel">
<!--Indicator Buttons-->
<ol class="carousel-indicators">
<li data-target="#randomCarousel" data-slide-to="0" class="active"></li>
<li data-target="#randomCarousel" data-slide-to="1"></li>
<li data-target="#randomCarousel" data-slide-to="2"></li>
</ol>
<!--Carousel w/Images-->
<div class="container">
<div class="carousel-inner">
<!--ALL PICS ARE PART OF CREATIVE COMMONS; ADDED SIMPLY FOR FUN-->
<div class="carousel-item active">
<img src="https://images.pexels.com/photos/459225/pexels-photo-459225.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="d-block w-100" alt="First">
</div>
<div class="carousel-item">
<img src="https://images.pexels.com/photos/2283759/pexels-photo-2283759.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="d-block w-100" alt="Second">
</div>
<div class="carousel-item">
<img src="https://images.pexels.com/photos/2283759/pexels-photo-2283759.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260" class="d-block w-100" alt="Third">
</div>
</div>
</div>
<!--Next and Previous buttons-->
<a class="carousel-control-prev" href="#randomCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#randomCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
https://codepen.io/pgurav/pen/KKKxBwM

Bootstrap 4 Carousel not sliding

I'm trying to use the bootstrap carousel, however is doesn't want to slide.
My current code is:
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="../../../../assets/foto-1.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../../../../assets/foto-2.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../../../../assets/foto-2.jpg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
</a>
</div>
in my index.html i have:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
Could anyone help me out?
I forgot to import JS. Thanks Boss COTIGA:
JavaScript is missing getbootstrap.com/docs/4.1/getting-started/introduction

carousel overlaps to fixed nav bar when view is changed

My HTML is this:
<div class="navbar navbar-fixed-top" >
some divs inside...
</div>
<div class="filler"> </div>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="first-slide" src="<?php print(base_url('assets/images/slide-one.jpg')); ?>" alt="First slide" />
<div class="container">
<div class="carousel-caption">
<div class="main-text">TEXT 1!</div>
<div class="sub-text">subtext</div>
</div>
</div>
</div>
<div class="item">
<img class="second-slide" src="<?php print(base_url('assets/images/slide-two.jpg')); ?>" alt="Second slide">
<div class="container">
<div class="carousel-caption">
<div class="main-text">TEXT 2</div>
<div class="sub-text">subtext </div>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
CSS:
.filler {
height: 230px; //same height of class navbar.i do this so
carousel will not overlap the fixed navbar
}
The design runs OK. The top div is fixed at the top. But when I change the view to smaller or to mobile view, the carousel overlaps the fixed navbar. How will I format my css so that carousel will not overlap? Or is there another way to format this? Thank you.

Twitter Bootstrap carousel - move indicators

I am trying to move my carousel indicators beneath the carousel. I've tried a few tips on the web to no avail.
I tried bottom with a negative value, but no good.
Any suggestions?
<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 for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="/bootstrap-3.1.1/images/carousel-1.jpg" alt="...">
<div class="carousel-caption">
ATS International Conference
</div>
</div>
<div class="item">
<img src="/bootstrap-3.1.1/images/carousel-1.jpg" alt="...">
<div class="carousel-caption">
ATS International Conference
</div>
</div>
<div class="item">
<img src="/bootstrap-3.1.1/images/carousel-1.jpg" alt="...">
<div class="carousel-caption">
ATS International Conference
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
You can insert your indicators where you want...
Bootply : http://www.bootply.com/SZqnwXVQ71
CSS:
.carousel-indicators{
position:relative;
background:grey;
height:25px;
bottom:0px;
}
.carousel-control{
margin-bottom:25px; // Same height as indicators
}
HTML :
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="/bootstrap-3.1.1/images/carousel-1.jpg" alt="...">
<div class="carousel-caption">
ATS International Conference
</div>
</div>
<div class="item">
<img src="/bootstrap-3.1.1/images/carousel-1.jpg" alt="...">
<div class="carousel-caption">
ATS International Conference
</div>
</div>
<div class="item">
<img src="/bootstrap-3.1.1/images/carousel-1.jpg" alt="...">
<div class="carousel-caption">
ATS International Conference
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
<!-- Indicators JUST MOVE IT DOWN-->
<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>

Resources