CSS Bootstrap 4 - 将轮播指示器更改为点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47235256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap 4 - change the carousel indicators into dots
提问by Lance Shi
I am using Bootstrap 4 Beta 2 version to do a carousel. The code looks like below:
我正在使用 Bootstrap 4 Beta 2 版本进行轮播。代码如下所示:
<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:
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?
有没有办法可以将指标更改为点而不是线?我认为这是一个引导程序选项,但我没有找到相关文档。我需要为此编写自定义 css 吗?
回答by Ddmteetu
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%
.
是的,我认为您需要编写自定义 CSS 来将线变成点。
您只需要覆盖两个属性 ( width
and height
) 并添加一个新属性border-radius
, 到.carousel-indicators li
。
制作width
和height
值等于例如:10px
每给予border-radius
的100%
。
.carousel-indicators li {
width: 10px;
height: 10px;
border-radius: 100%;
}
回答by Ayan Bhattacharjee
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.
如果您有图标路径,您只需要更改图标路径,使用检查元素可以获得类名。我使用 Mozilla 获取类名,然后使用两个 svg 图标将默认图标更改为自定义图标。
.carousel-control-prev-icon {
background-image: url("images/carousel/back.svg");
}
.carousel-control-next-icon {
background-image: url("images/carousel/next.svg");
}
回答by Glen
I had to include .carousel for it to work properly.
我必须包含 .carousel 才能正常工作。
.carousel .carousel-indicators li {
width: 10px;
height: 10px;
border-radius: 100%;
}