Only Show 3 Carousel Indicators on Bootstrap 3 carousel - css

I have Bootstrap 3 carousel on my page, there are more than 10 carousel slides, i want to display only 3 Indicators for the carousel because i dont want to show N number of Indicators because the slide images comes dynamically!!
After the Carousel crosses the 3rd slide (auto scroll/change enabled), the 3rd Indicator should remain active until the Carousel changes to the first slide. How to achieve this?

Supposing that the html of your carousel is the following
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
<li data-target="#myCarousel" data-slide-to="4"></li>
<li data-target="#myCarousel" data-slide-to="5"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="la.jpg" alt="Los Angeles" style="width:100%;">
</div>
<div class="item">
<img src="chicago.jpg" alt="Chicago" style="width:100%;">
</div>
<div class="item">
<img src="ny.jpg" alt="New york" style="width:100%;">
</div>
<div class="item">
<img src="ny.jpg" alt="New york" style="width:100%;">
</div>
<div class="item">
<img src="ny.jpg" alt="New york" style="width:100%;">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
here you have five slides and five indicators. For me, the easiest solution is a css solution (so, no js involved): you must simply add a class to the indicators that you want to hide, more precisely a class to the indicators that follow the last indicator that you want to make visible and a different class to the indicators that preceed the indicators that you want to hide, for example
<!-- Indicators -->
<ol class="carousel-indicators">
<li class="not-visible-sx" data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
<li data-target="#myCarousel" data-slide-to="4"></li>
<li class="not-visible-dx" data-target="#myCarousel" data-slide-to="5"></li>
</ol>
and then use this css code
.not-visible-sx{
position: absolute;
top: 3px;
border: none;
}
.not-visible-dx{
position: absolute;
top: 3px;
border: none;
margin-left: -12px
}
(border:none is needed to have a better look of the indicators)
You'r simply hiding them behind the first and last "visible".

Related

How can I change my buttons shape in carousel from lines in round

I want to change those indicators from carousel in round
I tried the code below and many others, not even one worked. Only was changed a little in round corners.
.carousel-indicators li {
border-radius: 12px;
width: 12px;
height: 12px;
background-color: #404040;
}
<div class="container">
<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 src="img/Background.png" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="img/Layer_4.png" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="img/Layer_5.png" class="d-block w-100" alt="...">
</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>
I need this: https://imgur.com/nx6mwdi
If I'm understanding correctly, you're looking to change the bullet of the list item?
You'll want to use a un-ordered list<ul> instead of an ordered list <ol>. So make that change in your HTML.
<ul 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>
</ul>
Then change your CSS to this:
.carousel-indicators li {
list-style-type: circle;
}

how to enable touch dynamic slider and choose first pic

I have a dynamic slider with botstrap in asp.net MVC; But I can not move it in touch.I use some sample jQuery Code for enable touch but it's important to me chose first pic of Slider automatically!
this is my HTML Code For dynamic Slider.
#model IEnumerable<MyProject.Models.DataSource.Sliders>
#if (Model.Any())
{
<section class="banner parallax-fix parallaximg">
<div class="container-fluid pr">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0"
class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
#foreach (var item in Model)
{
if (item.IsFirst == true)
{
<div class="item active">
<a onclick="SliderCounter(#item.SliderID)"
href="#item.SliderLink"
target="_blank">
<img src="~/images/Slider/#item.SliderImage"
alt="#item.SliderTitle"
style="width:100%;">
</a>
</div>
}
else
{
<div class="carousel-item item">
<a onclick="SliderCounter(#item.SliderID)"
href="#item.SliderLink"
target="_blank">
<img src="~/images/Slider/#item.SliderImage"
alt="#item.SliderTitle"
style="width:100%;">
</a>
</div>
}
}
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-
slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-
slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</section>
}
if you have another way for touchable and dynamic slider please help me!

Carousel ok in Site.Master, but not inside Content element

My carousel picture show works well when placed inside Site.Master, but the same markup inside the Content element of an .aspx file that uses Site.Master (without the carousel snippet) displays only the alt text for each image that it cycles through.
Environment: Win10 Pro, Visual Studio 2017 Community 15.4.4, bootstrap 3.0.0
Here is the carousel snippet:
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Images-->
<div class="carousel-inner" role="listbox">
<div class="item carousel-item active">
<img src="1945_DeHavilland_Canada_DH-98_Mosquito_FBMK26.jpg" alt="Slide #1">
</div>
<div class="item carousel-item">
<img src="1969_Aerovodochody_L-29_DELFIN.jpg" alt="Slide #2">
</div>
<div class="item carousel-item">
<img src="737BahamasAir.jpg" alt="Slide #3">
</div>
</div>
<!-- Left Right Arrows -->
<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>
If the file you are using the display the carousel is inside of a subfolder, example:
/wwwroot/Content/file.aspx
Then you would have to set the image source to ../example_image.jpg (or wherever the image is stored, in this case, the image is in your web root folder.

width carousel Bootstrap

I have a carousel with bootstrap, I want the width 100% on the title of the picture. I tried this, but it doesnt works .carousel-caption {
width : 500px;
}
<div id="myCarousel" class="carousel slide col-md-12" 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>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
<li data-target="#myCarousel" data-slide-to="4"></li>
</ol>
<!-- Wrapper for slides -->
<div id="divres" class="carousel-inner peopleCarouselImg" role="listbox">
<div class="item active">
<a href="resultado.php">
<div>
<img src="foto.png" alt="Chania">
<div class="carousel-caption">
<h1 class="img-rounded">EL MEJOR AUTO DEL MUNDO</h1>
</div>
</div>
</a>
</div>
</div>
<!-- Left and right controls -->
<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">Anterior</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">Siguiente</span>
</a>
</div>
I want 100% width
The CSS
.carousel-caption {
background-color: black;
}
You need to set the width to 100% to cover full width.The margin-left is used to move towards left that the carousel's left navigation button is occupying.
.carousel-caption {
background-color: black;
width:100%;
margin-left:-15%;
}
#media screen and (min-width:768px){
.carousel-caption {
background-color: black;
width:100%;
margin-left:-20%;
}
}

Bootstrap caurosel control options

Hi all am using bootstrap carousel my problem is i need to add show previous control only after clicking the first slide and if the slide ends has to disable the next control.!
how do i get this.
my caurosel looks like
<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="..." alt="...">
<div class="carousel-caption">
...
</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 could conditionally show the controls by determining the current slide like this..
$('#myCarousel').on('slid.bs.carousel', function (ev) {
var carouselData = $(this).data('bs.carousel');
var currentIndex = carouselData.getActiveIndex();
if (currentIndex >= 1) {
$('.left').show();
}
else {
$('.left').hide();
}
if (currentIndex === (carouselData.$items.length-1)) {
$('.right').hide();
$('.left').show();
}
else {
$('.right').show();
}
})
Demo: http://www.bootply.com/R11GWNqkSh

Resources