Reputation: 295
The Placeholder color is red. The default text field value is #444. What I want, If i click the text field, the placeholder color will change. But the default color should not be changed. Is it possible to do?
Please see my fiddle.
CSS:
.add_product input[type=text]{ color:#444;}
::-webkit-input-placeholder {
color: #D72D2E;
}
:-moz-placeholder { /* Firefox 18- */
color: #D72D2E;
}
::-moz-placeholder { /* Firefox 19+ */
color: #D72D2E;
}
:-ms-input-placeholder {
color: #D72D2E;
}
::-webkit-input-placeholder:focus {
color: #F3797A;
}
:-moz-placeholder:focus { /* Firefox 18- */
color: #F3797A;
}
::-moz-placeholder:focus { /* Firefox 19+ */
color: #F3797A;
}
:-ms-input-placeholder:focus {
color: #F3797A;
}
Upvotes: 1
Views: 1197
Reputation: 36995
Move the :focus
before ::placeholder
:
:focus::-webkit-input-placeholder //etc
Upvotes: 3
Reputation: 15213
You are setting the :focus
on the placeholder
but it should be on the input
:
:focus::-webkit-input-placeholder {
color: #F3797A;
}
:focus:-moz-placeholder { /* Firefox 18- */
color: #F3797A;
}
:focus::-moz-placeholder { /* Firefox 19+ */
color: #F3797A;
}
:focus:-ms-input-placeholder {
color: #F3797A;
}
Note that not all browser support this. IE for example hides the placeholder
when you focus on the input
.
Upvotes: 1