首页 > 解决方案 > 文本区域的占位符颜色

问题描述

我有一个如下所示的文本区域。

textarea::placeholder {
  color: #999 !important;
}

textarea::-moz-placeholder {
  color: #999 !important;
}

input[type='text']::placeholder, textarea::placeholder{
    color:#999 !important;
}
<input type="text" placeholder="Check List" name="check_list" /><br/>
<textarea rows="4" cols="50" placeholder="Description" name="description"></textarea>

我得到如下输出

在此处输入图像描述

我为Check ListDescription字段应用相同的颜色。但输出不一样。为什么输出不一样?

在此处输入图像描述

我的Check ListCSS 如下所示

input[type='text']::placeholder, textarea::placeholder{
    color:#999 !important;
}

标签: htmlcss

解决方案


您正在将样式应用于<textarea/>元素,但清单元素是<input type='text'/>. 您需要将 css 样式应用于input[type='text']或任何您想要的选择器。


推荐阅读