Prevent overlapping the text in textarea

Johannes has the solution if you want the scroll bar alongside the whole container. This is not a fix to the padding inconsistency between Chrome/Firefox just another way so you can avoid it.

Keeping the padding consistent and avoiding “trial and error” positioning.

To note: div max-width: 400px and other max-width/widths can be changed if needed this was a style choice to make it responsive.

textarea:focus This stops Chrome from adding an outline on the textarea – if you need accessibility then I would not do this or make it pretty. */

div {
  width: 100%;
  max-width: 400px;
  position: relative;
}

label {
  display: block;
  color: blue;
  background: #fff;
  border: 1px solid #000;
  width: 100%;
  box-sizing: border-box;
  padding: 5px 20px 10px 10px;
  border-bottom: none;
}

textarea {
  display: block;
  padding: 0 25px 25px 25px;
  width: 100%;
  max-width: 100%;
  min-width: 100%;
  min-height: 200px;
  border: 1px solid #000;
  border-top: none;
  box-sizing: border-box;
  position: relative;
  top: -1px;
}

textarea:focus {
  outline: none;
}
<div class="text-area-container">
  <label>Some label</label>
  <textarea>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</textarea>

</div>

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top