[英]Can I customize text color of a React-Bootstrap Form Control input textbox?
I am trying to create a form on a website using React-Bootstrap Form elements, but I want it to match the current color scheme of the website.我正在尝试使用 React-Bootstrap Form 元素在网站上创建表单,但我希望它与网站的当前配色方案相匹配。 I was able to make the background color of the inputs the desired color (using.form-control in CSS), but I can't seem to change the placeholder text color, which is currently gray.
我能够将输入的背景颜色设置为所需的颜色(在 CSS 中使用.form-control),但我似乎无法更改当前为灰色的占位符文本颜色。 Additionally, when I click on the input box, the whole text box becomes white and reverts to the default color scheme.
此外,当我单击输入框时,整个文本框变为白色并恢复为默认配色方案。 I have tried setting the 'color' property of the Form.Control elements in CSS, but to no avail.
我尝试在 CSS 中设置 Form.Control 元素的“颜色”属性,但无济于事。
Here is the HTML and CSS I have right now, and a screenshot of what the website looks like vs. what I want it to look like.这是我现在拥有的 HTML 和 CSS,以及网站外观与我想要的外观的屏幕截图。 As you can see, the 'color' property isn't changing the text color.
如您所见,“颜色”属性不会更改文本颜色。 In the first picture, I have clicked into the last text box to show what I mean by reverting to the default color scheme.
在第一张图片中,我单击了最后一个文本框,以显示恢复为默认配色方案的含义。
HTML: HTML:
<Form id="contact-form">
<Form.Group controlId="formBasicName">
<Form.Control type="name" placeholder="Name" />
</Form.Group>
<Form.Group controlId="formBasicEmail">
<Form.Control type="email" placeholder="Email" />
</Form.Group>
<Form.Group controlId="formBasicSubject">
<Form.Control type="subject" placeholder="Subject" />
</Form.Group>
<Form.Group controlId="exampleForm.ControlTextarea1">
<Form.Control as="textarea" rows="4" placeholder="Type your message here..." />
</Form.Group>
<Button id="submit-button" variant="light" type="submit">
Submit
</Button>
</Form>
CSS: CSS:
#contact-form {
margin: 20px;
width: 800px;
}
.form-control {
height: 50px;
border-radius: 0;
background-color: #876f49;
color: white;
border-color: white;
border-width: 1.3px;
}
Original:原来的:
Attempt (I have clicked into the last text box to show what it turns into):尝试(我点击了最后一个文本框以显示它变成了什么):
What I want it to look like:我希望它看起来像什么:
Is there any way I can further customize the Form Control colors, or should I just make my own form without Bootstrap?有什么方法可以进一步自定义表单控件 colors,还是应该在没有 Bootstrap 的情况下制作自己的表单?
I have a similar project in which I made use of CSS's not psuedo-class:我有一个类似的项目,其中我使用了 CSS 的非伪类:
CSS: CSS:
.form-control:not(active){
color:white;
}
.form-control:focus{
color:black;
}
In this example the 'not(active)' will change the color whenever the fields are not selected.在此示例中,只要未选择字段,“not(active)”就会更改颜色。 The 'focus' will change the color when a user clicks on the field to enter data.
当用户单击字段输入数据时,“焦点”将改变颜色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.