【发布时间】:2015-04-28 05:37:53
【问题描述】:
我对文本区域占位符有疑问。我需要在我的项目中将占位符显示为 2 行。我使用 placeholder::after css 将占位符显示为两行。但是 Mozilla 和 IE 不支持文本区域的占位符::after css。我怎么解决这个问题。我需要为每个行占位符使用单独的样式。有人说 after 和 before 不适用于文本区域。所以请帮我解决这个问题。
谷歌浏览器运行良好。
在此处查看小提琴...PLACEHOLDER FIDDLE
textarea::-webkit-input-placeholder{
text-align:center;
font-size:34px;
line-height:35px;
}
textarea:-moz-placeholder{
text-align:center;
font-size:34px;
line-height:35px;
}
textarea::-moz-placeholder{
text-align:center;
font-size:34px;
line-height:35px;
}
textarea:-ms-input-placeholder{
text-align:center;
font-size:34px;
line-height:35px;
}
textarea::-webkit-input-placeholder::after{
display: block;
text-align:center;
content:"For example, when you last spoke to your customer";
font-size:20px;
line-height:20px;
}
textarea:-moz-placeholder:after{
display: block;
text-align:center;
content:"For example, when you last spoke to your customer";
font-size:20px;
line-height:20px;
}
textarea::-moz-placeholder::after{
display: block;
text-align:center;
content:"For example, when you last spoke to your customer";
font-size:20px;
line-height:20px;
}
textarea:-ms-input-placeholder::after{
display: block;
text-align:center;
content:"For example, when you last spoke to your customer";
font-size:30px;
line-height:20px;
}
<textarea maxlength="25000" style="margin-bottom: 0px; height: 70px; width: 99%;" placeholder="Start Typing here..." ></textarea>
【问题讨论】:
-
据我所知,对于所有浏览器支持,您不能使用纯 css 作为多行占位符。我有一个使用 jquery 的技巧,你可以使用它。检查:jsfiddle.net/pdXRx/616
-
@ketan 谢谢你。我的问题是第二行占位符需要单独的样式。请帮我解决。