I am trying to resize a bootstarp 4 carousel. But after I done that. There are some white background left.
I've tried making the background transparent, none. margin, border, padding to 0. box-shadow to none.
Nothing helps.
But if I add class "carousel-caption" aside of "carousel" or "float: left;" the white background will be gone.
I wish to know if there is any other methods to fix this problem. And what is causing it.
Codepen: https://codepen.io/kudratullah/pen/bmdNjp (The Codepen isn't belongs to me, but it shares the same problem of mine.)
If you turned all the background colors to black, you can still sees the left/right side of the carousel will be still in white background.
Screen Shot: Codepen
My codes are at below:
HTML:
<div id="demo" class="carousel slide slider-horizontal" data-ride="carousel">
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
<li data-target="#demo" data-slide-to="1" class="active"></li>
<li data-target="#demo" data-slide-to="2" class="active"></li>
</ul>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="Picture.jpg">
</div>
<div class="carousel-item">
<img src="Picture.jpg">
</div>
<div class="carousel-item">
<img src="Picture.jpg">
</div>
</div>
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
CSS:
.slider-horizontal
{
width: 60%;
margin: auto;
}
.carousel-inner img
{
width: 100%;
}
Many Thanks!!
Please use additional container class and change background to black.Here's the solution:
body
{
background: black!important;
}
.container{
background:black;
}
.slider-horizontal
{
width: 60%;
margin: auto;
}
.carousel-inner img
{
width: 100%;
}
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div id="demo" class="carousel slide slider-horizontal" data-ride="carousel">
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
<li data-target="#demo" data-slide-to="1" class="active"></li>
<li data-target="#demo" data-slide-to="2" class="active"></li>
</ul>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://image.shutterstock.com/image-photo/lovely-beach-picture-beautiful-260nw-1554809048.jpg">
</div>
<div class="carousel-item">
<img src="https://image.shutterstock.com/image-photo/lovely-beach-picture-beautiful-260nw-1554809048.jpg">
</div>
<div class="carousel-item">
<img src="https://image.shutterstock.com/image-photo/lovely-beach-picture-beautiful-260nw-1554809048.jpg">
</div>
</div>
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
</body>
If you want something else, please let me know.