简体   繁体   中英

different placeholder text styles in the same form

Does anyone know if it is possible to have different styles for the placeholder text in the same form?

So far I have

::-webkit-input-placeholder {
   color:#000 !important;
}

:-moz-placeholder { /* Firefox 18- */
   color:#000 !important;  
}

::-moz-placeholder {  /* Firefox 19+ */
   color:#000 !important;  
}

:-ms-input-placeholder {  
   color:#000 !important;  
}

which works great for making the text black; however I also want to have blue text in a different

Here you Go:

Working Example

CSS:

    ::-webkit-input-placeholder { color:#f00; }
    input:-moz-placeholder { color:#f00; }

    input:-ms-placeholder { color:#f00; }
    ::-ms-input-placeholder { color:#f00; }
    :-ms-input-placeholder  { color:#f00; }

    /* individual */
    #field2::-webkit-input-placeholder { color:#00f; }
    #field3::-webkit-input-placeholder { color:#090; background:lightgreen; text-transform:uppercase; }
    #field4::-webkit-input-placeholder { font-style:italic; text-decoration:overline; letter-spacing:3px; color:#999; }

Mark up:

<p><input type="search" placeholder="Field 1" id="field1" /></p>
<p><input type="search" placeholder="Field 2" id="field2" /></p>
<p><input type="search" placeholder="Field 3" id="field3" /></p>
<p><input type="search" placeholder="Field 4" id="field4" /></p>

If you have different classes on your inputs or different input types, you can do something like this:

input[type='text']::-webkit-input-placeholder {
    color: #000;
}

input[type='email']::-webkit-input-placeholder {
    color: red;
}

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