Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing font-family for placeholder

Is it posible for an input field to have one font-family and it's placeholder another?

I have tried to change font-family for the input's placeholder with an already defined @font-face in CSS but it's not working:

CSS

    .mainLoginInput::-webkit-input-placeholder {        font-family: 'myFont', Arial, Helvetica, sans-serif;     }          .mainLoginInput:-moz-placeholder {        font-family: 'myFont', Arial, Helvetica, sans-serif;     } 

HTML

    <input class="mainLoginInput" type="text" placeholder="Username"  /> 

How can I solve this problem?

like image 982
Goldie Avatar asked Jan 25 '13 14:01

Goldie


People also ask

How do I change my placeholder font family?

Placeholder text will automatically inherit the font family and font size of the regular input text, but you may be in a situation where you want to change the placeholder text color. You can accomplish that with the ::placeholder pseudo-element.

How do I change the text style of a placeholder?

In most browsers, the placeholder text is grey. To change this, style the placeholder with the non-standard ::placeholder selector.

How do I change placeholder text in CSS?

Change Input Placeholder Text with CSS You can use the ::placeholder pseudo-element to change the styles of the placeholder text, which includes the ability to change the background. The code in this example uses a Sass function to generate code for support in older browsers as well.

How do you change font of placeholder in React Native?

To change font family for TextInput placeholder in React Native, we can set the fontFamily style of the TextInput . to set the fontFamily property to 'courier' to render the text inputted in the TextInput with Courier.


1 Answers

In case someone want the placeholders selectors for all browsers :

.mainLoginInput::-webkit-input-placeholder {   font-family: 'myFont', Arial, Helvetica, sans-serif; }  .mainLoginInput:-ms-input-placeholder {   font-family: 'myFont', Arial, Helvetica, sans-serif; }  .mainLoginInput:-moz-placeholder {   font-family: 'myFont', Arial, Helvetica, sans-serif; }  .mainLoginInput::-moz-placeholder {   font-family: 'myFont', Arial, Helvetica, sans-serif; } 
like image 188
Preview Avatar answered Sep 29 '22 08:09

Preview