Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stack two images side by side in bootstrap carousel

I'm trying to do two things:

1) Stack two images side by side on a bootstrap carousel

2) I'd like to show 2 images side by side in desktop view and only one image in the mobile view.

Here's my bootply: http://www.bootply.com/6UtgjHqm8f

I added

.carousel-inner .item img {
  display: inline-block;
}

Which helps, but my alignment is off. The first image goes way off to the left and crowds the left navigation.

Here's my HTML:

   <div class="content-section-b">

    <div class="container">

        <div class="row">
            <div class="col-lg-12">
                <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 class="img-responsive" src="http://www.onvia.com/responsive/apples_01.png" alt="Apples">
                      <img class="img-responsive" src="http://www.onvia.com/responsive/oranges_01.png" alt="Oranges">
                    </div>
                    <div class="item">
                      <img class="img-responsive" src="http://www.onvia.com/responsive/pears_01.png" alt="Pears">
                      <img class="img-responsive" src="http://www.onvia.com/responsive/mangos_01.png" alt="Mangos">
                    </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>

    </div>
    <!-- /.container -->

</div>
<!-- /.content-section-b -->

Here's my CSS:

    .content-section-b {
    padding: 50px 0;
    background-color: #3C5A78;
}

.carousel-control.left {
    background-image:none;
}

.carousel-control.right {
    background-image:none;
}
like image 687
user3075987 Avatar asked Feb 25 '26 09:02

user3075987


1 Answers

problem is with you image css property use inline-block on img tab and every thing will be ok

bootply Demo

like image 177
Adnan Akram Avatar answered Feb 27 '26 02:02

Adnan Akram