Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change text color from an input element while typing (css)

I have a search box and I want the color of the text in white. I changed the placeholder color to white and the text color to white, but the text color only turns white when the person clicks out of the form (while typing it remains the grey Bootstrap color).

How can I change it? My style.scss code:

.form-control {
  background-color: transparent !important;
  color: white;

  &::placeholder {
    color: white;
    opacity: 1;
  }
}
like image 797
Flávia Nunes Avatar asked Jan 03 '19 13:01

Flávia Nunes


People also ask

How do you change the color of your text when typing?

Go to Format > Font > Font. + D to open the Font dialog box. Select the arrow next to Font color, and then choose a color.

How do you change the text color of an element in CSS?

Simply add the appropriate CSS selector and define the color property with the value you want. For example, say you want to change the color of all paragraphs on your site to navy. Then you'd add p {color: #000080; } to the head section of your HTML file.

How do I change input color in CSS?

To change the selected option color of the menu, the “:checked” selector of CSS is used. :checked is a pseudo-class element that can be only linked with input type elements, such as “option”, “checkbox”, and “radio buttons”. It is mainly used to change the behavior of the selected value of these elements.


1 Answers

For your problem focus pseudo class should work:

#searchFieldText:focus {  // set your searchbox with focus pseudo class
    color: #fff; // put your color here
}

Let me know if this works.

like image 124
clauub Avatar answered Sep 21 '22 14:09

clauub