How can I change Bootstrap carousel indicators into dots?

Viewed 63993

I am using Bootstrap 4 Beta 2 version to do a carousel. The code looks like below:

                <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>
                </ol>

And the carousel indicator show as lines: enter image description here

Is there a way I can change the indicators into dots instead of lines? I would assume it is an bootstrap option but I didn't find that relevant document. Do I need to write custom css for that?

6 Answers

Yes, I think you need to write custom CSS for doing lines into dots.
You just need to override two properties (width and height) and add a new one, border-radius, to .carousel-indicators li.
Make width and height values equal eg: 10px each and give a border-radius of 100%.

.carousel-indicators li {
  width: 10px;
  height: 10px;
  border-radius: 100%;
}

In bootstrap 5 if you change what's in the comments it works.

.carousel-indicators [data-bs-target] {
    box-sizing: content-box;
    flex: 0 1 auto;
    width: 10px; /* change width */
    height: 10px; /* change height */
    padding: 0;
    margin-right: 3px;
    margin-left: 3px;
    text-indent: -999px;
    cursor: pointer;
    background-color: #fff;
    background-clip: padding-box;
    border: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    opacity: .5;
    transition: opacity .6s ease;
    border-radius: 100%; // /* add border-radius */
}

Example: image of dots

I had to include .carousel for it to work properly.

.carousel .carousel-indicators li {
   width: 10px;
  height: 10px;
  border-radius: 100%;
}

You just need to change the icon path in case you have one, using the inspect element you can get the class name. I used Mozilla to get the class name and then I used two svg icons for changing the default icons to custom icons.

.carousel-control-prev-icon {

    background-image: url("images/carousel/back.svg");

}

.carousel-control-next-icon {

    background-image: url("images/carousel/next.svg");

}

You must override the inline style using the word !important. This overrides any other styling that the element has.

I was able to style the indicators into circles with a bluish color by doing the following:

.carousel-indicators button {
    height: 10px !important;
    width: 10px !important;
    margin: 0 10px !important;
    border-radius: 100%;
    background-color: #1963ac !important;
}

The modern Bootstrap carousel is now laying them out as buttons.

use this:

.carousel-indicators li {
        width: 1rem;
        height: 1rem;
        border: 1px solid;
        border-radius: 50%;
        background-color: #E0E0E0;
    }
    
    .carousel-indicators .active {
        background-color: #000000;
    }
Related