Bootstrap 4 - change the carousel indicators into

2020-05-23 03:42发布

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?

3条回答
Lonely孤独者°
2楼-- · 2020-05-23 04:26

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%;
}
查看更多
Root(大扎)
3楼-- · 2020-05-23 04:33

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");

}
查看更多
成全新的幸福
4楼-- · 2020-05-23 04:35

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

.carousel .carousel-indicators li {
   width: 10px;
  height: 10px;
  border-radius: 100%;
}
查看更多
登录 后发表回答