简体   繁体   English

我可以自定义 React-Bootstrap 表单控件输入文本框的文本颜色吗?

[英]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.

相关问题 如何在 React-Bootstrap 中删除输入边框? - How can I remove input border in React-Bootstrap? 如何使用引导程序将复选框与文本输入表单控件紧密对齐? - How can I tightly align a checkbox with a text input form control using bootstrap? 如何制作 HTML 验证所需的 React-Bootstrap 无线电组? - How can I make a React-Bootstrap radio group required with HTML validation? 如何在 JQuery 中控制多个输入文本 - How can I control multiple input-text in form in JQuery 如何更改引导程序表单方向,文本右侧文本框左侧? - How can I change bootstrap form direction, text right textbox left? 使用 react-bootstrap 将空间添加到表单标签的开头? - Space being added to the start of a form label using react-bootstrap? 表单控件中的Bootstrap输入文本出现了一些不必要的空白 - Bootstrap input text in form-control is taking some unwanted margins 如何在引导程序中将表单输入标签和段落的文本颜色更改为白色 - How to change text color to white for form input labels and paragraphs in bootstrap Bootstrap - 如何将输入文本(类型=数字)控件的宽度减少到 N 个数字空格 - Bootstrap - How can I reduce the width of input text (type=number) control to N number of digit spaces 自定义引导程序导航栏颜色 - customize bootstrap navbar color
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM