admin管理员组文章数量:1023758
I am trying to change the styling of Form.Control when checked from the default green to #2196F3.
I have tried a few ways and nothing seems to change it. The closest I have gotten is:
CSS:
.col input[type="radio"]:checked {
background-color: #2196F3;
}
React:
<Col>
<Form.Check type='radio' label='No Unsubs' onChange={() => this.handleRadio('false')} checked={this.state.unsub === 'false'}/>
</Col>
This does not actually change the color though. It does show up in Chrome's developer's tools, but it still shows as green. I can not figure out where the green es from. Any ideas?
I am trying to change the styling of Form.Control when checked from the default green to #2196F3.
I have tried a few ways and nothing seems to change it. The closest I have gotten is:
CSS:
.col input[type="radio"]:checked {
background-color: #2196F3;
}
React:
<Col>
<Form.Check type='radio' label='No Unsubs' onChange={() => this.handleRadio('false')} checked={this.state.unsub === 'false'}/>
</Col>
This does not actually change the color though. It does show up in Chrome's developer's tools, but it still shows as green. I can not figure out where the green es from. Any ideas?
Share Improve this question asked Jan 22, 2020 at 20:06 zboyerzboyer 211 silver badge2 bronze badges3 Answers
Reset to default 2For react-bootstrap:1.6.1 - You should :
Add "custom" props to Form.Check.
Change border-color and background-color in
.custom-control-input:checked ~ .custom-control-label::before
For example:
<F.Form.Check
custom
checked={true}
type='radio'
key={id}
label={
<div className={`document-name ${className}`}>{`${documentName} ${fullName}`}
<div className={`issuer-name ${className}`}>{issuerName}</div>
</div>
}
/>
Then you can see .custom-control-input:checked ~ .custom-control-label::before in dev tools
Because the radio button is a native element , you can't change its color/style directly.
Try to overlay the radio button style using :after
, something like below
input[type='radio']:after {
width: 15px;
height: 15px;
border-radius: 15px;
top: -2px;
left: -1px;
position: relative;
background-color: #e6f7e6;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid rgb(157, 194, 241);
}
input[type='radio']:checked:after {
width: 15px;
height: 15px;
border-radius: 15px;
top: -2px;
left: -1px;
position: relative;
background-color: #e6f7e6;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid rgb(131, 240, 42);
}
It may not work when you give className on the form.Control and try applying custom CSS. Please trying applying custom CSS using id on form.Control instead of className
<Form.Control
placeholder="Mobile number or email address"
className="facebook_inputs"
id="form_control"
type="text"
/>
#form_control{
background: rgba(0, 0, 0, 0.261);
}
now we can see the given background color applied on that input field
I am trying to change the styling of Form.Control when checked from the default green to #2196F3.
I have tried a few ways and nothing seems to change it. The closest I have gotten is:
CSS:
.col input[type="radio"]:checked {
background-color: #2196F3;
}
React:
<Col>
<Form.Check type='radio' label='No Unsubs' onChange={() => this.handleRadio('false')} checked={this.state.unsub === 'false'}/>
</Col>
This does not actually change the color though. It does show up in Chrome's developer's tools, but it still shows as green. I can not figure out where the green es from. Any ideas?
I am trying to change the styling of Form.Control when checked from the default green to #2196F3.
I have tried a few ways and nothing seems to change it. The closest I have gotten is:
CSS:
.col input[type="radio"]:checked {
background-color: #2196F3;
}
React:
<Col>
<Form.Check type='radio' label='No Unsubs' onChange={() => this.handleRadio('false')} checked={this.state.unsub === 'false'}/>
</Col>
This does not actually change the color though. It does show up in Chrome's developer's tools, but it still shows as green. I can not figure out where the green es from. Any ideas?
Share Improve this question asked Jan 22, 2020 at 20:06 zboyerzboyer 211 silver badge2 bronze badges3 Answers
Reset to default 2For react-bootstrap:1.6.1 - You should :
Add "custom" props to Form.Check.
Change border-color and background-color in
.custom-control-input:checked ~ .custom-control-label::before
For example:
<F.Form.Check
custom
checked={true}
type='radio'
key={id}
label={
<div className={`document-name ${className}`}>{`${documentName} ${fullName}`}
<div className={`issuer-name ${className}`}>{issuerName}</div>
</div>
}
/>
Then you can see .custom-control-input:checked ~ .custom-control-label::before in dev tools
Because the radio button is a native element , you can't change its color/style directly.
Try to overlay the radio button style using :after
, something like below
input[type='radio']:after {
width: 15px;
height: 15px;
border-radius: 15px;
top: -2px;
left: -1px;
position: relative;
background-color: #e6f7e6;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid rgb(157, 194, 241);
}
input[type='radio']:checked:after {
width: 15px;
height: 15px;
border-radius: 15px;
top: -2px;
left: -1px;
position: relative;
background-color: #e6f7e6;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid rgb(131, 240, 42);
}
It may not work when you give className on the form.Control and try applying custom CSS. Please trying applying custom CSS using id on form.Control instead of className
<Form.Control
placeholder="Mobile number or email address"
className="facebook_inputs"
id="form_control"
type="text"
/>
#form_control{
background: rgba(0, 0, 0, 0.261);
}
now we can see the given background color applied on that input field
本文标签: javascriptChanging color of ReactBootstrap FormControl elementsStack Overflow
版权声明:本文标题:javascript - Changing color of React-Bootstrap Form.Control elements - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745539434a2155113.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论