如何删除textarea中的底部填充?

时间:2017-08-25 22:53:14

标签: javascript jquery html css

如何删除textarea中的底部填充?

$('textarea').css("height", $("textarea").prop("scrollHeight"))
textarea {
  width: 300px;
  resize: none;
  margin: 0;
  padding: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a </textarea>

1 个答案:

答案 0 :(得分:1)

你应该使用

溢出-y:隐藏

如下:

&#13;
&#13;
$('textarea').css("height", $("textarea").prop("scrollHeight"))
&#13;
textarea {
  width: 300px;
  resize: none;
  margin: 0;
  padding: 0;
  overflow-y: hidden;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a </textarea>
&#13;
&#13;
&#13;