Pau*_*ung 34 html css carousel twitter-bootstrap bootstrap-4
我显然在这里错过了一些愚蠢的东西.我有白色背景的图像,所以我希望能够编辑Bootstraps Carousel上的箭头,以便它们可见.如此多的改变箭头的颜色(不像我做的那样背景).
CSS
.carousel-control-prev-icon, .carousel-control-next-icon {
height: 100px;
width: 100px;
outline: black;
background-color: rgba(0, 0, 0, 0.3);
background-size: 100%, 100%;
border-radius: 50%;
border: 1px solid black;
}
Run Code Online (Sandbox Code Playgroud)
轮播HTML
<div class = 'col-md-9'>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block img-fluid" src="carousel/Bars%20and%20Dots.jpg" alt="First slide" class = 'img-responsive'>
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="carousel/murial.jpg" alt="Second slide" class = 'img-responsive'>
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="carousel/Upper%20Partialism%20album%20covers004white.jpg" alt="Third slide" class = 'img-responsive'>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
Fra*_* A. 94
我知道这是一个较旧的帖子,但它帮助了我.我还发现,对于bootstrap v4,您还可以通过覆盖控件来更改箭头颜色,如下所示:
.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") !important;
}
.carousel-control-next-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='M2.75 0l-1.5 1.5 2.5 2.5-2.5 2.5 1.5 1.5 4-4-4-4z'/%3E%3C/svg%3E") !important;
}
Run Code Online (Sandbox Code Playgroud)
您fill='%23fff'
将末尾的fff 更改为您想要的任何十六进制值的位置.例如:
fill='%23000'
黑色,fill='%23ff0000'
红色等.只是一个注释,我没有在没有!important声明的情况下测试过.
小智 44
我希望这有效,欢呼.
.carousel-control-prev-icon,
.carousel-control-next-icon {
height: 100px;
width: 100px;
outline: black;
background-size: 100%, 100%;
border-radius: 50%;
border: 1px solid black;
background-image: none;
}
.carousel-control-next-icon:after
{
content: '>';
font-size: 55px;
color: red;
}
.carousel-control-prev-icon:after {
content: '<';
font-size: 55px;
color: red;
}
Run Code Online (Sandbox Code Playgroud)
Chr*_*ena 39
如果只想在Bootstrap 4中将它们变黑。
.carousel-control-next,
.carousel-control-prev {
filter: invert(100%);
}
Run Code Online (Sandbox Code Playgroud)
小智 6
您还应该使用:<span><i class="fa fa-angle-left" aria-hidden="true"></i></span>
使用fontawesome。您必须覆盖原始代码。执行以下操作,您将可以在CSS上进行自定义:
<a class="carousel-control-prev" href="#carouselExampleIndicatorsTestim" role="button" data-slide="prev">
<span><i class="fa fa-angle-left" aria-hidden="true"></i></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicatorsTestim" role="button" data-slide="next">
<span><i class="fa fa-angle-right" aria-hidden="true"></i></span>
<span class="sr-only">Next</span>
</a>
Run Code Online (Sandbox Code Playgroud)
原始代码
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
Run Code Online (Sandbox Code Playgroud)
目前,Bootstrap 4 使用带有嵌入 SVG 数据信息的背景图像,其中包括 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"); }
Run Code Online (Sandbox Code Playgroud)
注意关于fill='%23fff'
它的部分用颜色填充形状,在这种情况下为#fff(白色),红色只需替换为#f00
最后,包含此内容是安全的(下一个图标的更改相同):
.carousel-control-prev-icon {background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23f00' 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"); }
Run Code Online (Sandbox Code Playgroud)