twitter-bootstrap 如何自定义 Bootstrap Carousel 控件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17158562/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 17:21:30  来源:igfitidea点击:

How to Customize Bootstrap Carousel Controls

twitter-bootstrap

提问by Mona Coder

Can you please let me know how I can customize the Bootstrap Carousel Controls for example I would like to change the size of the controls, or bg colors and How I can add background image to the controls? I tried to replace the with bootstrap Icons but they positioned at the top of control and didn't work properly

您能否让我知道如何自定义 Bootstrap Carousel 控件,例如我想更改控件的大小或 bg 颜色以及如何向控件添加背景图像?我试图用引导程序图标替换,但它们位于控件的顶部并且无法正常工作

<a class="carousel-control left" href="#this-carousel-id" data-slide="prev"><i class=" icon-arrow-right icon-white"></i></a>
<a class="carousel-control right" href="#this-carousel-id" data-slide="next">&rsaquo;</a>

the output looks like:

输出看起来像:

enter image description here

在此处输入图片说明

回答by Alvin

How familiar are you with CSS?

你对 CSS 有多熟悉?

What I see in your screenshot could be adjusted via font-size and line-height properties

我在您的屏幕截图中看到的内容可以通过 font-size 和 line-height 属性进行调整

Bootstrap is a CSS framework so customization is just a matter of overriding defaults, often using an id tag or something similar

Bootstrap 是一个 CSS 框架,因此定制只是覆盖默认值的问题,通常使用 id 标签或类似的东西

回答by parfa

This worked for me for the size and color:

这对我的尺寸和颜色有用:

.carousel-control .icon-prev, .carousel-control .icon-next {
    font-size: 100px; 
    margin-top: -50px;
    color: #fff;
}

回答by pax

one quick way to change the colour is to override the inline svg background:

更改颜色的一种快速方法是覆盖内联 svg 背景:

.carousel-control-prev-icon {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 8 8'%3E%3Cpath d='M5.25 0l-4 4 4 4 1.5-1.5-2.5-2.5 2.5-2.5-1.5-1.5z'/%3E%3C/svg%3E");
}

look for the fill='%23fff'part and change the colour, from white to something else: fill='%23444'or fill='RoyalBlue'

寻找fill='%23fff'零件并更改颜色,从白色变为其他颜色:fill='%23444'fill='RoyalBlue'