'Text only carousel
I am unable to have a carousel with only text without any img. The text seems to be colliding with the controls. Every example I've found uses the <img>. I have tried to use d-flex class, block and even the carousel-caption. Nothing has worked so far.
<div id="carouselContent" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<p>lorem ipsum (imagine longer text)</p>
</div>
<div class="carousel-item">
<p>lorem ipsum (imagine longer text)</p>
</div>
</div>
<a class="carousel-control-prev" href="#carouselContent" 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="#carouselContent" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Solution 1:[1]
I added px-5 everywhere (in your case in p). I needed space around and also added a class to it that gave it a margin of 20px. This worked.
Solution 2:[2]
Try the container object
<div id="carouselContent" class="carousel slide" data-ride="carousel">
<div class="container">
<div class="carousel-inner text-center text-white m-auto" role="listbox">
<div class="carousel-item active text-center p-4">
<div class="user_text mb-3">
<p class="mbr-fonts-style display-7">
<strong>
Blah
</strong><br>
</p>
</div>
</div>
<div class="carousel-item text-center p-4">
<div class="user_text mb-3">
<p class="mbr-fonts-style display-7">
<strong>
Blah Blah
</strong><br>
</p>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselContent" 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="#carouselContent" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Solution 3:[3]
Change:
<div class="carousel-caption d-none d-md-block"></div>
To:
<div class="carousel-caption"></div>
.slider-wrap {
background-color: #F0F0F0;
padding-top: 5rem;
padding-bottom: 8rem;
margin-bottom: 5rem;
text-align: center;
}
.carousel-indicators {
margin-bottom: 0!important;
}
.carousel-text {
margin: 1rem;
}
.carousel-caption {
margin: auto!important;
position: initial!important;
padding-right: 8rem;
padding-left: 8rem;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | double-beep |
| Solution 2 | Gary Cawley |
| Solution 3 | juji_ni |
