简体   繁体   中英

Input text aligning at the center with extra padding at the top and bottom

I'm creating an input element with a fixed height. But I'm getting some unwanted padding when I input a text both at the top and bottom. Also when the text is long, it is creating a horizontal scroll along the x-axis instead of splitting the line into 2 / multiples lines.

How to fix this?

在此处输入图像描述

 .input--custom { border: 0.1px solid #cfd7fd; padding: 5px; display: block; height: 100px; width: 100%; box-sizing: border-box; word-break: break-word; overflow: hidden; }.input--width { height: 100px; white-space: pre-wrap; overflow-wrap: break-word; }
 <div> <input type="textArea" placeholder="Type your message here and click submit" class="input--custom input--width "> </div>

You need to use a textarea element rather than an input element. See below and this entry on StackOverflow:

 .input--custom { border: 0.1px solid #cfd7fd; padding: 5px; display: block; height: 100px; width: 100%; box-sizing: border-box; word-break: break-word; overflow: hidden; }.input--width { height: 100px; white-space: pre-wrap; overflow-wrap: break-word; }
 <div> <textarea placeholder="Type your message here and click submit" class="input--custom input--width "></textarea> </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM