分类分类
更新时间:2015-07-09 08:41作者:fang
textArea的placeholder不能换行。例如:
<textarea placeholder="第1行 n 第2行 <br> 第3行 A 第4行
第5行"></textarea>
这是不会起作用的,会原封不动地输出。

官方不认为这是一个bug:
The placeholder attribute represents a short hint (a word or short phrase)
For a longer hint or other advisory text, the title attribute is more appropriate.
意思就是说placeholder表示的是一个简单的提示(一个词或者一个短语),根本不需要换行。如文本太长,那就用title。
但是实际应用中,我们有时需要换行。如何解决?很多时候我们用JavaScript来解决,其实CSS也可以实现。
由于placeholder属性是可以用css操作的,所以我们可以用:after来把placeholder的内容写到CSS中,曲线救国。
CSS Code
textarea::-webkit-input-placeholder:after{
display:block;
content:"line@ A line#";/* A 表示换行 */
color:red;
};
以上是webkit的代码,Firefox类也有相应的版本:
CSS Code
textarea::-moz-placeholder:after{
content:"line@ A line#";/* A 表示换行 */
color:red;
};
相关
纸片马里奥(Paperboat)角色扮演107.85 MBv1.0.32026-11-29
下载cyime输入法实用工具74.58 MBv1.15.1072026-11-29
下载武道仙宗官方版角色扮演456.19 Mv1.0.02026-11-29
下载mmrl模块app实用工具7.15 Mv342962026-11-29
下载零希沃特手机版角色扮演511.54 Mv1.4.22026-11-29
下载Bannerlator手游辅助574.84 MBv3.2.12026-11-29
下载巅峰激战(魔幻格斗游戏)动作射击797.1 MBv1.0.92026-11-29
下载我的火车防御策略游戏181.87 Mv1.1.52026-11-29
下载三国棋逢对手角色扮演1.7Gv1.2.5.0002.1125.11432026-11-29
下载图纸没问题手机版休闲益智78.41 Mv1.0.182026-11-29
下载蛊界永生角色扮演407.01 Mv0.4.162026-11-28
下载百炼仙途角色扮演528.9 Mv10002026-11-28
下载










