简体   繁体   中英

How to change placeholder's font-size but don't change the value's font-size in <input> by CSS?

How to change placeholder's font-size but don't change the value's font-size in <input> by CSS ?

When I focus on the <input> , placeholder's font size is already 12px, and then the value I input will be 16px. Just like this.

When I focus on the <input>

在此处输入图片说明

When I edit

在此处输入图片说明

Check this answer:

 ::-webkit-input-placeholder { font-size: 16px; } ::-moz-placeholder { font-size: 16px; } /* firefox 19+ */ :-ms-input-placeholder { font-size: 16px; } /* ie */ input:-moz-placeholder { font-size: 16px; } input { font-size:8px; height:30px; width:50%; text-indent:10px; }
 <input type="text" name="name" placeholder="Enter the name" />

You can try,

.your-class::-webkit-input-placeholder, .your-class::-moz-placeholder, .your-class:-ms-input-placeholder, .your-class:-moz-placeholder{
   font-size: 16px;
 }

or '*' for all placeholders.

From here

::-webkit-input-placeholder { font-size: 16px; }
::-moz-placeholder { font-size: 16px; } /* firefox 19+ */
:-ms-input-placeholder { font-size: 16px; } /* ie */
input:-moz-placeholder { font-size: 16px; }

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM