css - 如何更改占位符字体

标签 css

我目前正在尝试更改我的用户 ID 和密码字段的占位符字体。我在下面添加了 css,它更改了用户 ID 占位符字体而不是密码占位符字体,我不确定为什么。

有什么帮助吗?

::-webkit-input-placeholder { /* Chrome/Opera/Safari */
  font-family: 'helveticaneueregular', sans-serif !important;
}
::-moz-placeholder { /* Firefox 19+ */
      font-family: 'helveticaneueregular', sans-serif !important;
}
:-ms-input-placeholder { /* IE 10+ */
      font-family: 'helveticaneueregular', sans-serif !important;
}
:-moz-placeholder { /* Firefox 18- */
      font-family: 'helveticaneueregular', sans-serif !important;
}
	<input style="font-family: 'helveticaneueregular', sans-serif !important;" type="text" id="username" name="username" role="textbox" class="rememberMainField txt15 commonFont1Style2 clearTextField" placeholder="User ID" required="" autocapitalize="off" autocomplete="off" autocorrect="off" aria-label="Enter Your User ID" maxlength="50" minlength="3" pattern="^[^ ]+$" relinputid="RelativeClass0">

最佳答案

更多信息?在此示例中,它适用于两者:

.font1::-webkit-input-placeholder {
    font-family: "Times New Roman", Times, serif;
    background-color: yellow;
}

.font2::-webkit-input-placeholder { 
    font-family: Arial, Helvetica, sans-serif;
    background-color: pink;
}
Times New Roman placeholder font:<br/>
<input class="font1" placeholder="User ID">
<input class="font1" type="password" placeholder="Password">
<br/><br/>
Arial placeholder font:<br/>
<input class="font2" placeholder="User ID" >
<input class="font2" type="password" placeholder="Password">

关于css - 如何更改占位符字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53036424/

相关文章:

javascript - React - 如何通过 ref 应用样式

CSS:在不改变容器大小的情况下加粗一些文本

CSS:关于单选按钮的问题

jquery - 在悬停时突出显示其他列表中的相应列表项

css - 升级 Angular Material 打破了 md-input 换行符

html - 扩展内部 div 高度以满足外部 div 高度

css - 为什么 -moz-animation 不起作用?

不调整图像大小的CSS图像边框翻转效果?

html - 需要帮助将图片与文字对齐

javascript - CSS & JS div slider - 重复点击