I'm trying to get the default bootstrap carousel indicators to be very thin yellow lines stuck at the bottom as shown below.
I got them to be at the bottom of the page but I can't seem to change them into rectangles or change their color.
HTML
<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>
</ol>
CSS
.carousel-indicators {
margin: 0px;
height: 0px;
}
.carousel-indicators ol {
width: 100%;
}
.carousel-indicators li {
height: 3px !important;
border-radius: 0px !important;
width: 25%;
}
Something like this? Note that the width is not totally accurate because I just made it 33%.
.item img {
width: 100%;
height: auto
}
.carousel {
position: relative;
width: 200px;
height: 100px;
}
ol.carousel-indicators {
position: absolute;
bottom: 0;
margin: 0;
left: 0;
right: 0;
width: auto;
}
ol.carousel-indicators li,
ol.carousel-indicators li.active {
float: left;
width: 33%;
height: 10px;
margin: 0;
border-radius: 0;
border: 0;
background: transparent;
}
ol.carousel-indicators li.active {
background: yellow;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div id="carousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel" data-slide-to="0" class="active"></li>
<li data-target="#carousel" data-slide-to="1"></li>
<li data-target="#carousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://placehold.it/200x100" alt="Slide 1">
<div class="carousel-caption">
Slide 1
</div>
</div>
<div class="item">
<img src="http://placehold.it/200x100" alt="Slide 2">
<div class="carousel-caption">
Slide 2
</div>
</div>
<div class="item">
<img src="http://placehold.it/200x100" alt="Slide 3">
<div class="carousel-caption">
Slide 3
</div>
</div>
</div>
<a class="left carousel-control" href="#carousel" 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" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
Great css! I played with it to come up with ball indicators in half-white and the active indicator in yellow.
ol.carousel-indicators {
position: absolute;
bottom: 5px;
margin: 0;
left: 0;
right: 0;
width: auto;
}
ol.carousel-indicators li, ol.carousel-indicators li.active {
width: 1rem;
height: 1rem;
margin: 0;
border-radius: 50%;
border: 0;
background: transparent;
}
ol.carousel-indicators li {
background: rgba(255,255,255,0.39);
margin-left: .5rem;
margin-right: .5rem;
}
ol.carousel-indicators li.active {
background: yellow;
}
i have just wrote similar code for myself,
i think it will help you a little bit more.
by using Flex layout you can similarly stretch indicators
without worrying about their width
flex-grow:1; makes this job
https://codepen.io/ophiuch/pen/Jzowbo
.carousel /*slider */
{
position: relative;
}
.carousel .carousel-indicators /* indicator wrapper*/
{
position: absolute;
bottom: 0;
left:0px;
width: 100%;
margin: 0;
left: 0;
right: 0;
width: 100%;
display: flex; /* this is for indicators */
}
#headcarousel_container .carousel-indicators li /* indicators*/
{
flex-grow: 1; /* make all indicator li similarly stretched */
height: 40px;
border-radius: 2px;
}
#headcarousel_container .carousel-indicators li.active
{
background-color:rgba(251,222,87,0.5) ;/* changes indicators color when it is active*/
}
.carousel .carousel-inner .item img
{
width: 100%;
height: 100vh;
object-fit: cover;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Carousel</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<!--slider -->
<div class="container-fluid" id="headcarousel_container" style="padding: 0;">
<div id="headcarouselid" class="carousel slide" data-ride="carousel">
<!-- indicators -->
<ul class="carousel-indicators">
<li class="active" data-target="#headcarouselid" data-slide-to="0"></li>
<li class="" data-target="#headcarouselid" data-slide-to="1"></li>
<li class="" data-target="#headcarouselid" data-slide-to="2"></li>
<li class="" data-target="#headcarouselid" data-slide-to="3"></li>
<li class="" data-target="#headcarouselid" data-slide-to="4"></li>
</ul>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="https://cdn.pixabay.com/photo/2017/08/30/01/05/milky-way-2695569_960_720.jpg" title="slidepicture" alt="slidepicture">
</div>
<div class="item">
<img src="https://cdn.pixabay.com/photo/2014/07/28/20/39/landscape-404072_960_720.jpg" title="slidepicture" alt="slidepicture">
</div>
<div class="item">
<img src="https://cdn.pixabay.com/photo/2018/08/23/07/35/thunderstorm-3625405_960_720.jpg" title="slidepicture" alt="slidepicture">
</div>
<div class="item">
<img src="https://cdn.pixabay.com/photo/2017/09/08/20/29/chess-2730034_960_720.jpg" title="slidepicture" alt="slidepicture">
</div>
<div class="item">
<img src="https://cdn.pixabay.com/photo/2018/05/30/15/31/rustic-3441673_960_720.jpg" title="slidepicture" alt="slidepicture">
</div>
</div>
<!-- Left and right controls -->
<a class="carousel-control left" href="#headcarouselid" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="carousel-control right" href="#headcarouselid" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</body>
</html>
This snippet changes prev and next Carousel icon controls for library react-bootstrap :
& span.carousel-control-prev-icon, & span.carousel-control-next-icon{
background-color: black;
}
Yeah, only the background. The icon itself is an xml image so couldn't find a way to change the colors. :/
Related
I am trying to have same height at my carousel:
html
<div class="container">
<div id="carouselPortfolio" class="carousel slide" data-ride="carousel" data-interval="5000">
<ol class="carousel-indicators">
<li data-target="#carouselPortfolio" data-slide-to="0" class="active"></li>
<li data-target="#carouselPortfolio" data-slide-to="1"></li>
<li data-target="#carouselPortfolio" data-slide-to="2"></li>
<li data-target="#carouselPortfolio" data-slide-to="3"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<h5 id="hPortfolio">Hi there bkasbdjksbakdjbsakjbdks jbkdsabdk jkbdsakbdks jkbdsakbdnkjsab</h5>
<p><span class="FColorA">hbshabs hbsajhbdsa UJBAudbau undsaJNDBAIS</span></p>
<img class="d-block w-100" src="images/site.png" alt="First slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselPortfolio" 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="#carouselPortfolio" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
and css
h5{
font-family: 'Comfortaa', cursive;
/* font-family: 'Caudex', serif; */
font-weight: bold;
color: #14BEB4;
font-size: 100%;
word-wrap: break-word;
overflow:hidden;
}
.carousel-indicators li {
border-radius: 100%;
color: #323232;
background-color: #323232;
}
.carousel-caption{
padding: 5% 5%;
}
/* πιθανη αλλαγή */
.carousel-item{
padding: 0% 15%;
width: 100%;
height: 100% !important;
object-fit: cover;
}
.carousel-control-next-icon:after
{
content: '>';
font-size: 55px;
color: red;
}
.carousel-control-prev-icon:after {
content: '<';
font-size: 55px;
color: red;
}
I want to have same height at my carousel and dots not lines to change slides and if it is possible the dots over images, like text.
not wrapping text, to have same height mainContPortfolio and dots instead of dashes ...
Thank you.
I am using Bootstrap version 4.0.0-beta and I am using the carousel function. I have configured it perfectly as to how I need it when I view it on my monitor. (1920 x 1200) but would like to change it's height depending on the users monitor, for example 1920 x 1080. I have given my Carousel a height of 32rem but would like to decrease that size if a user is on a smaller screen like I said. I believe a media query is what I need but I have tried and can't figure it out. Can anyone shine some light on this please?
Thanks.
Managed to solve it on my own. Just used this.
#media screen and (max-height: 1000px) {
.carousel-item {
height: 24rem;
}}
Please try the sample below and let me know if its worked.
.img-responsive,
.thumbnail>img,
.thumbnail a>img,
.carousel-inner>.item>img,
.carousel-inner>.item>a>img {
display: block;
width: 100%;
height: auto;
}
.carousel-inner {
border-radius: 15px;
}
.carousel-caption {
background-color: rgba(0, 0, 0, .5);
position: absolute;
left: 0;
right: 0;
bottom: 0;
z-index: 10;
padding: 0 0 10px 25px;
color: #fff;
text-align: left;
}
.carousel-indicators {
position: absolute;
bottom: 0;
right: 0;
left: 0;
width: 100%;
z-index: 15;
margin: 0;
padding: 0 25px 25px 0;
text-align: right;
}
.carousel-control.left,
.carousel-control.right {
background-image: none;
}
.carousel-containers {
padding: 10px 0;
}
.carousel-containers {
background-color: #fff;
color: #555;
}
#media screen and (min-width: 768px) {
.carousel-containers {
padding: 1.5em 0;
}
}
#media screen and (min-width: 992px) {
.container {
max-width: 930px;
}
}
<div class="carousel-containers">
<div class="container">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<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 class="carousel-inner">
<div class="item active">
<img src="http://placehold.it/800x400" alt="...">
<div class="carousel-caption">
<h2>Heading</h2>
</div>
</div>
<div class="item">
<img src="http://placehold.it/800x400" alt="...">
<div class="carousel-caption">
<h2>Heading</h2>
</div>
</div>
<div class="item">
<img src="http://placehold.it/800x400" alt="...">
<div class="carousel-caption">
<h2>Heading</h2>
</div>
</div>
</div>
<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>
</div>
</div>
I'm trying to get get some padding to sides of Twitter Bootstrap slider.
I'm using plain example codes from bootstrap sides with little modifications.
In bellow image you can see what I try to mean. Slider is right now 100% of page width , but I try get some darker are to show on sides (60% of page width.) So it should be left 20% middle 60% and right side 20%.
HTML:
<header id="karuselli" class="carousel slide row" >
<ol class="carousel-indicators">
<li data-target="#karuselli" data-slide-to="0" class="active"></li>
<li data-target="#karuselli" data-slide-to="1"></li>
<li data-target="#karuselli" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<div class="fill" style="background-image:url('https://placehold.it/1900x1080&text=Slide One');"></div>
<div class="carousel-caption">
<h2>Caption 1</h2>
</div>
</div>
<div class="item">
<div class="fill" style="background-image:url('https://placehold.it/1900x1080&text=Slide Two');"></div>
<div class="carousel-caption">
<h2>Caption 2</h2>
</div>
</div>
<div class="item">
<div class="fill" style="background-image:url('https://placehold.it/1900x1080&text=Slide Three');"></div>
<div class="carousel-caption">
<h2>Caption 3</h2>
</div>
</div>
</div>
<a class="left carousel-control" href="#karuselli" data-slide="prev">
<span class="icon-prev"></span>
</a>
<a class="right carousel-control" href="#karuselli" data-slide="next">
<span class="icon-next"></span>
</a>
</header>
SCSS:
$karusellikorkeus : 50%;
$paneelikorkeus : 25px;
$menuValikkoYksi : 50%;
.menuValikkoYksi {
margin-right: 20%;
}
html,
body {
height: 100%;
background-color: #8c8c8c;
}
.carousel {
height: $karusellikorkeus;
}
.carousel-control.left, .carousel-control.right {
background-image: none
}
.item,
.active,
.carousel-inner {
height: 100%;
}
.body-top-padding {
padding-top: $paneelikorkeus + 90px;
}
.marginaali {
margin-top: $paneelikorkeus;
#include vp-background-size(cover);
}
.fill {
width: 100%;
height: 100%;
background-position: center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
hr {
color: red;
background-color: red;
padding: 2px 2px 2px 2px ;
}
footer {
margin: 50px 0;
}
Try this code
.carousel {
height: 50%;
width: 60%;
margin: 0 auto;
}
DEMO
while studying of bootstrap to navbar menus and carousel, i encountered this problem i tried something changing some codes but it doesnt worked. explain to me what is happen and which one is error. you can run the snippet to see what happen to my carousel
$(window).scroll(function() {
if($(this).scrollTop() > 50) /*height in pixels when the navbar becomes non opaque*/
{
$('.opaque-navbar').addClass('opaque');
} else {
$('.opaque-navbar').removeClass('opaque');
}
});
$('#myCarousel').carousel();
var winWidth = $(window).innerWidth();
$(window).resize(function () {
if ($(window).innerWidth() < winWidth) {
$('.carousel-inner>.item>img').css({
'min-width': winWidth, 'width': winWidth
});
}
else {
winWidth = $(window).innerWidth();
$('.carousel-inner>.item>img').css({
'min-width': '', 'width': ''
});
}
});
body {
background: #97744a;
}
section
{
background:yellow;
}
.banner
{
background: url(https://jonesbrotherscoffee.com/img/grindedcoffee300.jpg) fixed;
min-height:200px;
}
.banner .row
{
text-align:center;
margin-top:50px;
}
.banner h1
{
color:white;
}
.opaque-navbar {
background-color: rgba(0,0,0,0.5);
/* Transparent = rgba(0,0,0,0) / Translucent = (0,0,0,0.5) */
height: 60px;
border-bottom: 0px;
transition: background-color .5s ease 0s;
}
.opaque-navbar.opaque {
background-color: black;
height: 60px;
transition: background-color .5s ease 0s;
}
ul.dropdown-menu {
background-color: black;
}
#media (max-width: 992px) {
body
{
background: ;
}
.opaque-navbar {
background-color: black;
height: 60px;
transition: background-color .5s ease 0s;
}
}
.navbar-brand img {
width: 190px;
height: auto;
margin-top: -12px;
}
.active a {
background-color: #eeab1f !important;
}
/* main page */
.jumbotron {
border-top: 5px solid #cb8f50;
border-bottom: 5px solid #754b24;
border-right: 0px;
border-left: 0px;
min-height: 200px;
background-color: #422a1e;
}
.jumbotron img {
width: 500px;
height: auto;
margin: 0 auto;
display: block;
}
.jumbotron h2, h3 {
margin-top: -5px;
font-weight: bold;
color: #eeab1f;
}
.jumbotron p {
font-weight: lighter;
color: #ffffff;
font-size: 15px;
}
.jumbotron img {
width: 450px;
height: auto;
}
.right {
margin-top: 40px;
}
.right img{
width: 25px;
}
.carousel-inner > .item > img, .carousel-inner > .item > a > img {
display: block;
height: 400px;
min-width: 100%;
width: 100%;
max-width: 100%;
line-height: 1;
margin: 0 auto;
}
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Conlins Coffee World Inc.</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="js/jquery.min1.js"></script>
<script src="js/javascript-redirect.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans:300,400,700&subset=latin-ext" rel="stylesheet">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top opaque-navbar">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navMain">
<span class="glyphicon glyphicon-chevron-right" style="color:white;"></span>
</button>
<a class="navbar-brand" href="#"><img src="images/brands/artisans.png"></a>
</div>
<div class="collapse navbar-collapse" id="navMain">
<ul class="nav navbar-nav pull-right">
<li class="active">Home</li>
<li>Products</li>
<li>About Us</li>
<li>Contact Us</li>
<li></li>
</ul>
</div>
</div>
</div>
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="" contenteditable="false"></li>
<li data-target="#myCarousel" data-slide-to="1" class="active" contenteditable="false"></li>
<li data-target="#myCarousel" data-slide-to="2" class="" contenteditable="false"></li>
</ol>
<div class="carousel-inner">
<div class="item" style="">
<img src="http://www.dogbehaviour.org.uk/wp-content/uploads/2016/06/EH-Dog-behaviour.jpg" alt="" class="">
<div class="carousel-caption">
<h4 class="">First Slide Title</h4>
<p class="">
Description for First Slide, this First Slide.
</p>
</div>
</div>
<div class="item active">
<img src="http://www.oldnorthcanine.com/wp-content/uploads/2015/06/animal-dog-pet-sad-1920x500.jpg" alt="" class="">
<div class="carousel-caption">
<h4 class="">Second Slide Title</h4>
<p class="">
Description for Second Slide, this is Second Slide.
</p>
</div>
</div>
<div class="item" style="">
<img src="http://0104.nccdn.net/1_5/07f/260/1be/sophiebig.jpg" alt="" class="">
<div class="carousel-caption">
<h4 class="">Third Slide Title</h4>
<p class="">
Description for Third Slide, this is Third Slide.
</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</body>
</html>
$(window).scroll(function() {
if($(this).scrollTop() > 50) /*height in pixels when the navbar becomes non opaque*/
{
$('.opaque-navbar').addClass('opaque');
} else {
$('.opaque-navbar').removeClass('opaque');
}
});
$('#myCarousel').carousel();
var winWidth = $(window).innerWidth();
$(window).resize(function () {
if ($(window).innerWidth() < winWidth) {
$('.carousel-inner>.item>img').css({
'min-width': winWidth, 'width': winWidth
});
}
else {
winWidth = $(window).innerWidth();
$('.carousel-inner>.item>img').css({
'min-width': '', 'width': ''
});
}
});
body {
background: #97744a;
}
section
{
background:yellow;
}
.banner
{
background: url(https://jonesbrotherscoffee.com/img/grindedcoffee300.jpg) fixed;
min-height:200px;
}
.banner .row
{
text-align:center;
margin-top:50px;
}
.banner h1
{
color:white;
}
.opaque-navbar {
background-color: rgba(0,0,0,0.5);
/* Transparent = rgba(0,0,0,0) / Translucent = (0,0,0,0.5) */
height: 60px;
border-bottom: 0px;
transition: background-color .5s ease 0s;
}
.opaque-navbar.opaque {
background-color: black;
height: 60px;
transition: background-color .5s ease 0s;
}
ul.dropdown-menu {
background-color: black;
}
#media (max-width: 992px) {
body
{
background: ;
}
.opaque-navbar {
background-color: black;
height: 60px;
transition: background-color .5s ease 0s;
}
}
.navbar-brand img {
width: 190px;
height: auto;
margin-top: -12px;
}
.active a {
background-color: #eeab1f !important;
}
/* main page */
.jumbotron {
border-top: 5px solid #cb8f50;
border-bottom: 5px solid #754b24;
border-right: 0px;
border-left: 0px;
min-height: 200px;
background-color: #422a1e;
}
.jumbotron img {
width: 500px;
height: auto;
margin: 0 auto;
display: block;
}
.jumbotron h2, h3 {
margin-top: -5px;
font-weight: bold;
color: #eeab1f;
}
.jumbotron p {
font-weight: lighter;
color: #ffffff;
font-size: 15px;
}
.jumbotron img {
width: 450px;
height: auto;
}
.right img{
width: 25px;
}
.carousel-inner > .item > img, .carousel-inner > .item > a > img {
display: block;
height: 400px;
min-width: 100%;
width: 100%;
max-width: 100%;
line-height: 1;
margin: 0 auto;
}
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Conlins Coffee World Inc.</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="js/jquery.min1.js"></script>
<script src="js/javascript-redirect.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans:300,400,700&subset=latin-ext" rel="stylesheet">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top opaque-navbar">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navMain">
<span class="glyphicon glyphicon-chevron-right" style="color:white;"></span>
</button>
<a class="navbar-brand" href="#"><img src="images/brands/artisans.png"></a>
</div>
<div class="collapse navbar-collapse" id="navMain">
<ul class="nav navbar-nav pull-right">
<li class="active">Home</li>
<li>Products</li>
<li>About Us</li>
<li>Contact Us</li>
<li></li>
</ul>
</div>
</div>
</div>
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="" contenteditable="false"></li>
<li data-target="#myCarousel" data-slide-to="1" class="active" contenteditable="false"></li>
<li data-target="#myCarousel" data-slide-to="2" class="" contenteditable="false"></li>
</ol>
<div class="carousel-inner">
<div class="item" style="">
<img src="http://www.dogbehaviour.org.uk/wp-content/uploads/2016/06/EH-Dog-behaviour.jpg" alt="" class="">
<div class="carousel-caption">
<h4 class="">First Slide Title</h4>
<p class="">
Description for First Slide, this First Slide.
</p>
</div>
</div>
<div class="item active">
<img src="http://www.oldnorthcanine.com/wp-content/uploads/2015/06/animal-dog-pet-sad-1920x500.jpg" alt="" class="">
<div class="carousel-caption">
<h4 class="">Second Slide Title</h4>
<p class="">
Description for Second Slide, this is Second Slide.
</p>
</div>
</div>
<div class="item" style="">
<img src="http://0104.nccdn.net/1_5/07f/260/1be/sophiebig.jpg" alt="" class="">
<div class="carousel-caption">
<h4 class="">Third Slide Title</h4>
<p class="">
Description for Third Slide, this is Third Slide.
</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</body>
</html>
Remove margin-top
.right {
margin-top: 0px;
}
The effect I'm looking for can be seen in the following image, it is a carousel with 3 images.
How can I make the bootstrap carousel show the left and right images with an opacity of 0.7?
The following is my 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 for 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 to another question, if you add the following css to your code it will provide the effect you're looking for.
We basically have to expand .carousel-inner to be larger than .carousel, then center it and hide the overflow of .carousel.
To obtain the opacity effect, we expand the size of the previous and next arrow containers, then set a translucent white background.
Bootstrap >= 3.3.0
In Bootstrap version 3.3.0 there was a change in the CSS which invalidated the previous method. So this is the 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%;
}