1
Save everyone, I’m having trouble letting the width of a textarea track the line size, since its initial size does not currently expand.
My goal is to let the textarea only increase width as the user writes.
Follow the current code:
HTML:
<html>
<body>
<div class="container">
<div class="row">
<div class="col">
<p>
<textarea name="textarea" wrap="wrap" id="the_textarea" rows='1' class="textarea-cliente" placeholder="nome"></textarea>, esta textarea deveria expandir APENAS sua largura para acompanhar o tamanho do texto inserido dentro dela.
</p>
</div>
</div>
</div>
</body>
CSS:
textarea {
resize: none;
height: 30px;
overflow: hidden;
margin: -6px;
border: none;
}
.textarea-cliente {
min-width: 25%;
height: 24px;
width: auto;
}
I would like a light on this problem. From now on, thank you for understanding.
The html is broken, in the textarea div, in case what you want I did not understand well.
– Bulfaitelo
Dude you put a textarea within a paragraph? I don’t understand... Your HTML structure seems a little wrong... and you’re using the class
col-7
this will leave will not let the element stay with 100% of the width of the screen, if that’s what you want, because it did not give to understand well....– hugocsl
@Bulfaitelo Updated, I apologize for the problem.
– Nithogg
@hugocsl Structure redone, sorry for the error. Yes, had placed textarea within a paragraph. I was not aware of this limitation of col-7, since I used it only to increase its width.
– Nithogg
yes but your problem you want the textarea to expand as written or as the page size ?
– Bulfaitelo
You need to structure your grid correctly using
.container > .row > .col
(Docs). You also don’t seem to be wearing the form structures correctly (.form-group > textarea.form-control
).– fernandosavio
@Bulfaitelo As you write.
– Nithogg
both width and height ?
– Bulfaitelo
@Bulfaitelo Only width
– Nithogg
In fact what you want is that as the user type the
<textarea>
will go growing automatically is that it? Or you that a<textarea>
already 100% of the width?– hugocsl
@hugocsl Yes, let the <textarea> grow automatically.
– Nithogg
This is not possible. vc need to determine a size for it, be it 10% of the width of the screen or 100% of the width. It will not grow horizontally as you type, this is not a behavior that can be included in a <textarea> with CSS
– hugocsl
@hugocsl I understand, I will try to find other alternatives for such a solution. Thank you for the information!
– Nithogg
@Nithogg really I never saw, what I would recommend would be, let him 100% the div limit him, and make a self recycle down
– Bulfaitelo
@Nithogg something like this here http://www.jacklmoore.com/autosize/
– Bulfaitelo
@Bulfaitelo Based on this information, I will look for a different or similar solution, as your suggestion, but thank you for the information.
– Nithogg