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'
/>
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
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
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' />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.