-7

How to remove bottom padding in 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>
Patrick Evans
  • 41,991
  • 6
  • 74
  • 87
Cristian
  • 113
  • 4
  • 1
    There is no padding, I cannot see it – PRAISER Aug 25 '17 at 22:58
  • which browser you are using? – Manoj Aug 25 '17 at 23:01
  • You may want to look at this https://stackoverflow.com/questions/995168/textarea-to-resize-based-on-content-length – JFC Aug 25 '17 at 23:03
  • maybe there is other css causing it, you must provide a live version w or a fiddle so we can reproduce the problem – Aref Ben Lazrek Aug 26 '17 at 00:42
  • The textarea `scrollheight` is measured **before** the heigh change making the scrollbar dissapear... Which make the textarea innerwidth a little bit larger... The text then wraps to take that scrollbar space in width, leaving some white space at the bottom. @Farid's solution is to prevent any scroll bar... So the measurement made before the height change is correct. – Louys Patrice Bessette Aug 26 '17 at 02:50

1 Answers1

2

You should use

overflow-y: hidden

as folows

$('textarea').css("height", $("textarea").prop("scrollHeight"))
textarea {
  width: 300px;
  resize: none;
  margin: 0;
  padding: 0;
  overflow-y: hidden;
}
<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>
Farid Escate
  • 404
  • 5
  • 9