PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 23, 2022

[FIXED] How can I align Bootstrap Carousel indicator icons and arrow controls on the same line?

 July 23, 2022     bootstrap-4, mdbootstrap, twitter-bootstrap     No comments   

Issue

I use this carousel and love it: https://mdbootstrap.com/snippets/jquery/ascensus/135508#html-tab-view

The only thing is, I want the control to be around the indicators.

Currently, it's like this:

                  <            >
   SLIDE               SLIDE              SLIDE
                        ...

What I want:

   SLIDE               SLIDE              SLIDE
                 <      ...     >

already tried:

<!--Controls-->
<div class="controls-top">
    <a class="btn-floating" href="#multi-item-example" data-slide="prev"><i class="fa fa-chevron-left"></i></a>
    <!--Indicators-->
    <ol class="carousel-indicators">
        <li data-target="#multi-item-example" data-slide-to="0" class="active"></li>
        <li data-target="#multi-item-example" data-slide-to="1"></li>
        <li data-target="#multi-item-example" data-slide-to="2"></li>
    </ol>
    <!--/.Indicators-->
    <a class="btn-floating" href="#multi-item-example" data-slide="next"><i class="fa fa-chevron-right"></i></a>
</div>
<!--/.Controls-->

Anyone knows how I can achieve this with bootstrap classes without any wild css?


Solution

Changing the enclosing div of the carousel to a flex, changing the flex-order, and managing the extra margins did it.

The code becomes:

<div id="multi-item-example" class="carousel slide carousel-multi-item d-flex align-items-center justify-content-center flex-column" data-ride="carousel">
    <div class="controls-top order-1 d-flex">
        <a class="btn-floating" href="#multi-item-example" data-slide="prev"><i class="fa fa-chevron-left"></i></a>

        <ol class="carousel-indicators my-0 mx-5 position-relative d-flex align-items-center">
            <li data-target="#multi-item-example" data-slide-to="0" class="active m-0 mr-2"></li>
            <li data-target="#multi-item-example" data-slide-to="1" class="m-0 mr-2"></li>
            <li data-target="#multi-item-example" data-slide-to="2" class="m-0 mr-2"></li>
        </ol>

        <a class="btn-floating" href="#multi-item-example" data-slide="next"><i class="fa fa-chevron-right"></i></a>
    </div>

    <div class="carousel-inner" role="listbox">
        // carousel images and stuff
    </div>
</div>

Refer here: Snippet



Answered By - Siddharth Bhansali
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing