无法在Firefox textarea中关闭占位符换行

时间:2014-11-02 23:42:49

标签: html css firefox

在textarea中禁用包装的代码在webkit中完美运行,但在firefox中则不行。

演示(webkit):http://jsfiddle.net/cuk2072g/2/

代码:

#textArea {
  color: red;
  height: 200px;
  width: 300px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  resize: none;
}

#textArea::-webkit-input-placeholder {
  color: green;
  white-space: nowrap;
  overflow: hidden;
}
<textarea class="form-control" id="textArea" placeholder="_____________________________________________________________________________________________________________">
    </textarea>

Webkit完美无瑕,但Firefox有问题......

演示(firefox):http://jsfiddle.net/g7CsP/3/

代码:

#textArea {
  color: red;
  height: 200px;
  width: 300px;
  text-align: left;
  resize: none;
}

#textArea::-moz-placeholder {
  color: green;
  white-space: nowrap;
  overflow: hidden;
}
<textarea class="form-control" id="textArea" placeholder="_____________________________________________________________________________________________________________">
    </textarea>

1 个答案:

答案 0 :(得分:0)

我在这里找到了解决方案:它是第二高的答案 How remove word wrap from textarea?

CSS:

#textArea {
    color:red;
    height: 200px;
    width: 300px;
    text-align:left;
    word-wrap: normal;
    resize:none;
    }

#textArea::-moz-placeholder {
    color:green;
    }

http://jsfiddle.net/g7CsP/4/