Reputation: 61
I searched for a way to size a textarea
according to the rest of my layout and stumbled over the box-sizing method. I probably didn't use it correctly because it doesn't work for me. I have a layout that shows 3 different rows. The middle row should display a text-input field and below are all the recent posts. Now i want the textarea
to be the same width as my other postings.
HTML
<div class="row">
<div class="col-sm-2">
<!-- Empty Space -->
</div>
<div class="col-sm-2">
Some text here
</div>
<div class="col-sm-4">
<textarea placeholder="Text here"></textarea>
<div class="well"> Posts ...</div>
</div>
<div class="col-sm-2">
Some text here
</div>
<div class="col-sm-2">
<!-- Empty Space -->
</div>
</div>
And the css
textarea{
box-sizing: border-box;
border-radius: 5px;
resize: none;
}
Upvotes: 2
Views: 2567
Reputation: 3
textarea {
outline: none;
}
That should remove the glow witch resizes your textarea.
Upvotes: 0
Reputation: 2066
You can add the attribute width to the textarea
css
Like this:
width:100px; // you can change it to whatever width you want
textarea{
box-sizing: border-box;
border-radius: 5px;
resize: none;
width:100px; /* set you own width */
}
<div class="row">
<div class="col-sm-2">
<!-- Empty Space -->
</div>
<div class="col-sm-2">
Some text here
</div>
<div class="col-sm-4">
<textarea placeholder="Text here"></textarea>
<div class="well"> Posts ...</div>
</div>
<div class="col-sm-2">
Some text here
</div>
<div class="col-sm-2">
<!-- Empty Space -->
</div>
</div>
Upvotes: 0
Reputation:
You may be looking for
textarea {
width: 100%;
}
Your posts will automatically take up all the space in the column because div
s are block-level elements. See my Fiddle.
As a side note, the box-sizing property just defines the relation between specified width/height and computed width/height.
Upvotes: 2