I would like to set a textarea
to be 100% height. I'm using Bootstrap 3 but couldn't find an option there.
<div class="container">
<textarea class="form-control" rows="8"></textarea>
</div>
How to do it?
I would like to set a textarea
to be 100% height. I'm using Bootstrap 3 but couldn't find an option there.
<div class="container">
<textarea class="form-control" rows="8"></textarea>
</div>
How to do it?
html, body, .container {
height: 100%;
}
textarea.form-control {
height: 100%;
}
See demo on Fiddle
I believe this is a bootstrap issue. I ran into a similar problem where the textarea was not allowing for more than 1 row. I found (through trial and error) that placing the textarea in a div and then ignoring the form-group-(x) call within the first div, I was able to control the rows and the cols within the textarea.
<div class="form-group">
<label class="col-sm-3 control-label">Description</label>
<div class="col-sm-9">
<textarea class="form-control" rows="10"></textarea>
</div>
</div>
Changing your code to use the form-group functionality will correct the issue:
<div class="form-group">
<textarea class="form-control" rows="8"></textarea>
</div>
That should do the trick for you.
Doesn't work for me for bootstrap 3- davidkonrad You can try to modify the number of rows
<textarea class="form-control" cols="60" rows="16"></textarea>
or give a height fixed for the parent container
.form-group{
height:250px;
}
textarea{
height:100%;
}
You can use CSS:
textarea {
height: 100%;
}
Relative to the top layer.
This worked for me. I am using Bootstrap 3 as well. My textarea is inside a container.
textarea {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
This solves my problem.. I set the height to auto !important.
<label for="item_description" style="padding-top: 10px;">Item Description</label>
<textarea class="form-control" name="item_description" rows="3" style="height:auto !important;"></textarea>
.textarea {
position: absolute;
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
<!DOCTYPE HTML>
<html>
<head>
<title>Text Area</title>
</head>
<body>
<textarea class="textarea"></textarea>
<h3>subscribe to my youtube channel<a href="https://www.youtube.com/channel/UCsZ4Ue8c94YLJDbGRafCI5Q">The Gem Dev</a></h3>
</body>
</html>
This worked for me, i placed it in a container
.textarea {
position: absolute;
height: 100%;
width: 100%;
}
.textarea .text {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}