Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move bootstrap 3 carousel caption below images?

I have this html that shows slideshow images using bootstrap 3 :

<div class="col-sm-8">



            <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" role="listbox">
                {% for p in posts %}
                    {% if forloop.counter == 1 %}
                    <div class="item active">
                    {% else %}
                    <div class="item">
                   {% endif %}

                    {% if p.headimage %}
                    <img src="{{ p.headimage.url }}" alt="Image" width="460" height="345">
                     {% endif %}
                      <div class="carousel-caption">
                        <h3>{{ p.title }}</h3>
                        <p>{{ p.teaser }}</p>
                      </div>
                </div>
                {% endfor %}
                </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">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>

</div>

I want caption to be shown below the image, not over it.

I tried to manipulate the html and css but could not achieve this, so appreciate your help.

Update: Apart from native bootstrap, I have tried these custom css directives (which did not help):

.carousel-inner { padding-bottom:95px; }
.carousel-caption { bottom:-95px; }
like image 901
Jand Avatar asked May 08 '15 14:05

Jand


People also ask

How do I display Bootstrap carousel with three posts in each slide?

Following are the steps to create a Bootstrap carousel:Apply CSS to resize the . carousel Bootstrap card body by using the code segment below. In this step, the sliding images are defined in the division tag as under. Last step is to add controls to slide images using the carousel-control class as below.

How do you write a carousel caption?

Add captions to carousel images and set transition speed: To add a caption, hover over any image, click the “Add text” button, and select “Add caption”.

Does Bootstrap 3 have carousel?

Add scrolling images or text to your website with the Bootstrap carousel component. The Bootstrap carousel component enables you to add scrolling images and text that slide in, pause, then slide out. Controls enable the user to scroll forwards or backwards within the set.


2 Answers

Start by changing the position of the caption element from absolute to relative:

.carousel-caption {
    position: relative;
    left: auto;
    right: auto;
}

Demo

like image 161
isherwood Avatar answered Sep 19 '22 21:09

isherwood


I had a similar issue where I wanted the caption to be overlaid on the image on a large screen, and below the image in smaller sizes. I made overflow in .carousel-inner visible. I believe this would be a helpful, alternate way to position the caption text outside of the bound of the carousel images itself regardless of whether its part of a responsive element or not.

Edit: You must also change the height of the carousel (the containing div, not "inner") to accommodate the height of the image plus the caption.

.carousel-inner{
overflow: visible;
}
like image 26
Aaron Joseph Avatar answered Sep 20 '22 21:09

Aaron Joseph