[英]How to change a button icon color of a child element
I have a Modal.Header with a closeButton (which is white by default) and I want to change its color to black.我有一个带有 closeButton(默认为白色)的 Modal.Header,我想将其颜色更改为黑色。
The code for the component is:该组件的代码是:
const inlineStyles = {
header: {
padding: '18px',
margin: 0,
backgroundColor: '#F2F3F4',
},
<Modal.Header style={inlineStyles.header} closeButton >
The HTML of the rendered X-button looks like: <button type="button" aria-label="Close" class="close237497"></button>
呈现的 X 按钮的 HTML 如下所示:
<button type="button" aria-label="Close" class="close237497"></button>
Follow with this file of React-Bootstrap
.跟随这个
React-Bootstrap
文件。 When you pass a closeButton prop
into ModalHeader
, the button will has class is close
.当您将
closeButton prop
传递给ModalHeader
,该按钮的类将是close
。
So, you can override that class like this:因此,您可以像这样覆盖该类:
// create a file to override CSS bootstrap (override.css)
// override style of closeButton ModalHeader
.close {
color: #fc0303 !important // red
// orther style
}
import ModalHeader from 'react-bootstrap/ModalHeader';
import "./override.css";
// use ModalHeader
<ModalHeader closeButton />
使用Modal.Header
的 style 道具在button
设置样式,如下所示
<button type="button" aria-label="Close" style={this.props.style}></button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.