修改input中placeholder样式

实现方法: 使用::placeholder”选择器

::placeholder是css3新增的选择器,可能存在一定的浏览器兼容问题,所以最好加上不同的前缀 -ms- 、 -webkit- 、-ms- 等

input::placeholder {
    
    
   font-weight: 400;
   color: #624b2f;
}
//::-webkit-input-placeholder/* WebKit, Blink, Edge */
//:-moz-placeholder/* Mozilla Firefox 4 to 18 */
//::-moz-placeholder  /* Mozilla Firefox 19+ */
//:-ms-input-placeholder /* Internet Explorer 10-11 */
//::-ms-input-placeholder  /* Microsoft Edge */

这样就可以设置placeholder的字体大小、颜色的样式了

如果是微信小程序修改input中placeholder样式的话可以有两种:

1、使用placeholder-class
wxml中:

<input type="text" placeholder="这里是placeholder的内容" placeholder-class="placeholderClass"/>

wxss中:

.placeholderClass{
    
    
	font-weight: 400;
	color: #624b2f;
}

2、使用placeholder-style
wxml中:

<input type="text" placeholder="这里是placeholder的内容" placeholder-style="color: #624b2f;"/>

感觉就跟一个用类名一个用内联样式一样

猜你喜欢

转载自blog.csdn.net/weixin_44646763/article/details/118934563