【问题标题】:HTML5: Text area placeholder ::after content css not working in Mozilla and IEHTML5:文本区域占位符 ::after content css 在 Mozilla 和 IE 中不起作用
【发布时间】: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 谢谢你。我的问题是第二行占位符需要单独的样式。请帮我解决。

标签: css html


【解决方案1】:

我很确定多样式占位符不会跨浏览器或跨平台工作,因为它们都是依赖于设备的输入元素。 CSS3 支持仅限于少数属性,伪前/后不是其中之一。这篇文章列出了支持的属性:styling the html5 placeholder

可能的替代方法是在文本区域后面放置一些东西(div)并使文本区域稍微透明,直到被点击或使用图像作为占位符。我知道这两个都很讨厌。

【讨论】:

  • 感谢您的想法。我会像你的想法一样实施。
猜你喜欢
  • 2013-09-15
  • 2015-10-25
  • 2012-10-01
  • 1970-01-01
  • 2023-04-08
  • 2013-09-28
  • 2013-01-16
  • 1970-01-01
  • 2011-05-09
相关资源
最近更新 更多