0

I tried the following with the stylesheet and <input/> yet the color of the placeholder still has not changed and stays at the default color. Am I doing it incorrectly?

my css stylesheet:

#input-field {
  background-color: rgba(255,255,255,0.1);
  border: 0;
  border-radius: 5px;
  width: 150px;
  height: 40px;
  padding: 12px;
  box-shadow: none;
  color: rgba(255,255,255,0.8);
}

:-webkit-input-placeholder { /* WebKit, Blink, Edge */
    color:    blue;
}

:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
   color:    blue;
   opacity:  1;
}

::-moz-placeholder { /* Mozilla Firefox 19+ */
   color:    blue;
   opacity:  1;
}

:-ms-input-placeholder { /* Internet Explorer 10-11 */
   color:    blue;
}

And my <input/>:

  <input
    className="form-control"
    id="input-field"
    placeholder='Change This Color'
  />
  • 2
    Possible duplicate of [Change an input's HTML5 placeholder color with CSS](http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css) – Mehrad Sep 10 '16 at 00:03

3 Answers3

4

webkit needed two colons ::

#input-field {
  font-family: serif;
  background-color: rgba(255,255,255,0.1);
  border: 0;
  border-radius: 5px;
  width: 150px;
  height: 40px;
  padding: 12px;
  box-shadow: none;
  color: rgba(255,255,255,0.8);
}

::-webkit-input-placeholder {
   color: blue;
}

:-moz-placeholder { /* Firefox 18- */
   color: blue; 
   opacity:  1;
}

::-moz-placeholder {  /* Firefox 19+ */
   color: blue;  
   opacity:  1;
}

:-ms-input-placeholder {  
   color: blue;  
}
<input
    className="form-control"
    id="input-field"
    placeholder='Change This Color'
  />

to change the font-family add font-family: serif; to #input-field

Mehrad
  • 1,495
  • 14
  • 22
1

In your Html Page

<input
class="form-control"
id="input-field"
placeholder='Change This Color'
/>

in your css page

.form-control::-webkit-input-placeholder {
  color: red;
  width: 250px;
  font-family:Helvetica Neue;
}

font-family:Helvetica Neue is working for me here is the link

Bibek Shakya
  • 1,233
  • 2
  • 23
  • 45
  • Worked! Thank you so much! One last question before I accept the answer and upvote, how can I change the family-font of placeholder and typed text inside? –  Sep 09 '16 at 23:58
0

Simply put this code down. Your error was that you forgot to put a colon.

I put a lot of time in this, but it all comes down to putting another colon after :-webkit-input-placeholder, making it ::-webkit-input-placeholder.

I just discovered someone else answered the same exact way I did, and I don't mean to copy them, because I figured this out myself.

Take a look at the complete code. PS I made it look cursive for font-family.

#input-field {
  background-color: rgba(255, 255, 255, 0.1);
  border: 0;
  border-radius: 5px;
  width: 150px;
  height: 40px;
  padding: 12px;
  color: red;
  box-shadow: none;
  font-family: cursive;
}
::-webkit-input-placeholder {
  color: blue;
  font-family: cursive;
}
:-moz-placeholder {
  /* Firefox 18- */
  color: red;
  opacity: 1;
}
::-moz-placeholder {
  /* Firefox 19+ */
  color: red;
  opacity: 1;
}
:-ms-input-placeholder {
  color: red;
}
<input className="form-control" id="input-field" placeholder='Change This Color' />
Yash Jain
  • 1
  • 5
  • 20