Is it possible in Bootstrap to have the carousel indicators beside the carousel? I want some indicators on the right side to have font on them, so I know which slider I'm clicking on.
Picture to illustrate what I want:
You can put the controls wherever you want, these are the tagas that make them work. href="#myCarousel" point to the carousel id and data-slide="next" sets the behavior:
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">next</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="prev">prev</a>
Something like this may work for you: https://codepen.io/anon/pen/zNOOrQ
HTML
<div class="container">
<div class="page-header">
<h1>Bootstrap carousel with number indicator</h1>
</div>
</div>
<div class="container">
<div id="carousel-example-generic" class="carousel slide">
<!-- Indicators -->
<ol class="carousel-indicators carousel-indicators-numbers">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active">Slide 1</li><br>
<li data-target="#carousel-example-generic" data-slide-to="1">Slide 2</li><br>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://placehold.it/1200x500" alt="...">
</div>
<div class="item">
<img src="http://placehold.it/1200x500" alt="...">
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" 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="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
CSS
.carousel-indicators-numbers {
li {
display: block;
position: relative;
left:140%;
bottom: 150px;
text-indent: 0;
margin: 0 2px;
width: 70px;
height: 30px;
border: none;
line-height: 30px;
color: #fff;
background-color: #999;
transition: all 0.25s ease;
&.active, &:hover {
margin: 0 2px;
width: 70px;
height: 30px;
background-color: #337ab7;
}
}
}
Related
Am using bootstrap 4 carousel. Am trying to change the position of next and prev button to be at top right corner but close to each other. I have managed that but i think am making a mistake in my css code since when i minimize the screen I don't see the buttons.
Html code
<div id="featured" class="carousel slide" data-ride="carousel">
<!-- The slideshow -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="one.jpg">
</div>
<div class="carousel-item">
<img src="two.jpg" >
</div>
<div class="carousel-item">
<img src="three.jpg" >
</div>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#featured" data-slide="prev">
<span class="fa fa-arrow-circle-left fa-2x" style="color:green"></span>
</a>
<a class="carousel-control-next" href="#featured" data-slide="next">
<span class="fa fa-arrow-circle-right fa-2x" style="color:green"></span>
</a>
</div>
my css code
.carousel-control-prev,
.carousel-control-next{
width:20px;
height: 20px;
background-color: none;
top:calc(-20% -25%);
opacity:.8;
}
.carousel-control-prev{
left:1090px !important;
}
left:1090px !important is going to cause issues once the user's viewport hits close or less than 1090px. In retrospect, you should be able to asses why - because it is pushing it 1090px from left.
Do something like
.carousel-control-prev{
left: unset;
right: 30px;
}
instead, so you can control it from the right since you are positioning it upper-right
$('.carousel').carousel()
.carousel {
background: black;
}
.carousel .carousel-control-prev,
.carousel .carousel-control-next {
width: 20px;
height: 20px;
background-color: none;
top: calc(-20% -25%);
opacity: .8;
}
.carousel .carousel-control-prev {
left: unset;
right: 30px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<div id="featured" class="carousel slide" data-ride="carousel">
<!-- The slideshow -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://via.placeholder.com/650x200">
</div>
<div class="carousel-item">
<img src="https://via.placeholder.com/651x200">
</div>
<div class="carousel-item">
<img src="https://via.placeholder.com/652x200">
</div>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#featured" data-slide="prev">
<!--<span class="fa fa-arrow-circle-left fa-2x" style="color:green"></span>-->
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#featured" data-slide="next">
<!--<span class="fa fa-arrow-circle-right fa-2x" style="color:green"></span>-->
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
I am trying to create slider inside an image.
As to the attachment, I want to change the proportion of the background color and then to insert inside this div the slider.
I was using this example:
Fiddle here
The code:
HTML
<div class="col-6 col-md-4">
<img class="temp" src="img/phone.png">
<div class="bg-image">
<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>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="./img/testimonial-bg.jpg" alt="...">
</div>
<div class="item">
<img src="http://www.freedomwallpaper.com/nature-wallpaper/nature-hd-wallpapers-water.jpg" alt="...">
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" 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="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
CSS
#application img {
width: 250px;
height: 375px;
position: absolute;
}
.temp {
background: #440;
}
/*Image slider */
.bg-image {
width:250px;
height:350px;
background-repeat:no-repeat;
background-size:100%;
position: relative;
padding: 150px 0 0 0;
z-index: 1;
}
.carousel-inner>.item>a>img,
.carousel-inner>.item>img{
height: 350px;
}
Thank you for your help.
The container ('fifth-block' in my code) must go after my carousel (situated in 'fourth-block'). But the container is under the carousel. When reloading the page or scrolling the carousel, it is noticeable.
https://jsfiddle.net/l_zemlyanaya/9dxaxusm/4/
Here is my HTML code:
<div class="fourth-block">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="images/carousel-alyona.jpg" alt="Chania">
</div>
<div class="item">
<img src="images/carousel-lera.jpg">
</div>
<div class="item">
<img src="images/carousel-lesya.jpg">
</div>
</div>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="carousel-arrow glyphicon glyphicon-menu-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="carousel-arrow glyphicon glyphicon-menu-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<div class="fifth-block container-fluid">
<p class="proof-text">SOME TEXT</p>
</div>
And here is my CSS code:
.fourth-block {
width: 100%;
height: 300px;
}
#myCarousel {
height: 300px;
}
fifth-block {
background: #F2EADC;
padding-top: 30px;
height: 200px;
background-image: url("../images/pic3.jpg");
background-repeat: repeat;
}
.proof-text {
font-family: SummerFontLight;
font-size: 20px;
text-align: center;
}
The carousel should have been put in header
I'm fairly certain that this is a simple fix, but I've spent hours on it and am not sure why I haven't been able to fix it. Any help would be greatly appreciated!
My HTML is standard bootstrap:
<div class="row">
<div class="container" id="main">
<div class=col-md-12>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="5000">
<!-- 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>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="*IMAGE*" alt="Power Grid">
<div class="carousel-caption">
<h3>HELLO</h3>
<p>World</p>
</div>
</div>
<div class="item">
<img src="*IMAGE*" alt="Power Grid">
<div class="carousel-caption">
<h3>GOODBYE</h3>
<p>World</p>
</div>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" 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="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
Here is my current CSS:
#main.container {
padding: 0 10% 5% 10%;
}
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
width: 50%;
margin: auto;
}
#carousel-example-generic {
border: #000000 solid 10px;
border-radius: 15px;
}
I'm trying to replace bootstrap indicators circles with some glyphicons.
I tried to add glyphicon to carousel indicator, but not working.
http://jsfiddle.net/bn6aA/57/
HTML
<div id="locations" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators glyphicon glyphicon-refresh">
<li data-target="#locations" data-slide-to="0" class="active"></li>
<li data-target="#locations" data-slide-to="1"></li>
<li data-target="#locations" data-slide-to="2"></li>
<li data-target="#locations" data-slide-to="3"></li>
</ol>
<div class="carousel-inner">
<div class="item active ">
<img src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" alt="">
</div>
<div class="item">
<img src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" alt="">
</div>
<div class="item">
<img src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" alt="">
</div>
<div class="item">
<img src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" alt="">
</div>
</div>
<a class="left carousel-control" href="#locations" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#locations" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
Using glyphicons as carousel indicators is not such easy thing to do because we must do some modifications.I removed the class carousel-indicators from the list, i put the glyphicons inside the custom-list list items, and used my custom-list class to style the glyphicons.Also i removed the imported bootstrap-combined library because it was messing up the left and right carousel controls.
The above approach has one negative side which is we cannot style the glyphicon coresponding to the current active slide because we removed the carousel-indicators class from the list.
.custom-list li {
display: inline;
font-size: 40px;
color: #fff;
}
.custom-list li:hover {
color: #888;
cursor: pointer;
}
.item img {
width: 100%;
}
.custom-list {
top: 15px;
margin: auto;
position: absolute;
width: 50%;
top: 0;
left: 0;
bottom: 0;
right: 0;
text-align: center;
right: 15px;
z-index: 1;
list-style: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div id="locations" class="carousel slide" data-ride="carousel">
<ol class="custom-list">
<li data-target="#locations" data-slide-to="0" class="active"><span class="glyphicon glyphicon-th-large"></span>
</li>
<li data-target="#locations" data-slide-to="1"><span class="glyphicon glyphicon-th"></span>
</li>
<li data-target="#locations" data-slide-to="2"><span class="glyphicon glyphicon-th-list"></span>
</li>
<li data-target="#locations" data-slide-to="3"><span class="glyphicon glyphicon-list"></span>
</li>
</ol>
<div class="carousel-inner">
<div class="item active ">
<img src="http://placehold.it/900x200?text=First slide" alt="">
</div>
<div class="item">
<img src="http://placehold.it/900x200?text=Second slide" alt="">
</div>
<div class="item">
<img src="http://placehold.it/900x200?text=Third slide" alt="">
</div>
<div class="item">
<img src="http://placehold.it/900x200?text=Fourth slide" alt="">
</div>
</div>
<a class="left carousel-control" href="#locations" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#locations" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
Straight from the bootstrap website (http://getbootstrap.com/javascript/#carousel):
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" 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="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
However, something is going a little wonky here, so remove the circles like this with CSS
.carousel-control {
background: none !important;
border: none;
}
Proof: http://jsfiddle.net/bn6aA/65/
As you can see, this is still not rendering exactly correct. Some things are out of place and sized too big etc... This is because you are using bootstrap-combined.min.css V2.3.1 and bootstrap.css V3.0.0
Removing bootstrap-combined.min.css results in a much better looking solution: http://jsfiddle.net/bn6aA/64/