Change color of SVG background-image (Bootstrap 4 carousel)

岁酱吖の 提交于 2019-12-06 06:31:16

You can't style the contents of that SVG background image using CSS rules. It is parsed and processed and effectively turned into a bitmap image as it's decoded.

You would need to alter the SVG itself. Change the

fill='%23fff'

to

fill='%23000'

or to whichever colour you wish. The "%23" here is just the "#" symbol. It needs to be URL-encoded when used in a Data URI like this.

div {
  background-color: black;
}

button {
  width: 24px;
  height: 24px;
  border: none;
  background-color: transparent;
}

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


div.inverted {
  background-color: white;
}

.inverted .carousel-control-prev-icon {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' 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");
}
<div>
  <button class="carousel-control-prev-icon"></button>
</div>

<div class="inverted">
  <button class="carousel-control-prev-icon"></button>
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!