在bootstrap模态窗口中更改关闭按钮的颜色

Emm*_* P. 28 css twitter-bootstrap

我正在使用带有boostrap的模态窗口.我已经改变了背景和字体颜色,但我没有成功将右上角的关闭按钮更改为白色.

<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true" class="modal_button">&times;</span><span class="sr-only">Close</span></button>
Run Code Online (Sandbox Code Playgroud)

这是我的css属性

.modal-header {
  border-top: 1px solid white;
  border-left: 1px solid white;
  border-right: 1px solid white;
  text-align: left;
  font-size: 23px;
  color: white;
  background-color: #261f31;
  border-bottom: 0px;
}
Run Code Online (Sandbox Code Playgroud)

我想把X按钮变成白色

Ste*_*ers 43

Bootstrap设置颜色如下:

.close {
  float: right;
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
  color: #000;
  text-shadow: 0 1px 0 #fff;
  filter: alpha(opacity=20);
  opacity: .2;
}
Run Code Online (Sandbox Code Playgroud)

所以你可以用这个覆盖它:

.close {
    color: #fff; 
    opacity: 1;
}
Run Code Online (Sandbox Code Playgroud)

  • 不得不覆盖不透明度.`.close {color:#fff; 不透明度:1; }` (3认同)

str*_*myc 19

在 Bootstrap 5 中,他们有一个类允许您将关闭按钮的颜色更改为白色。

<button type="button" class="btn-close btn-close-white" aria-label="Close"></button>


小智 7

只需写下代码

filter: brightness(0) invert(1);
Run Code Online (Sandbox Code Playgroud)