20

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?

Jay
  • 511
  • 1
  • 13
  • 23

8 Answers8

16
html, body, .container {
  height: 100%;
}
textarea.form-control {
  height: 100%;
}

See demo on Fiddle

Stacked
  • 6,892
  • 7
  • 57
  • 73
davidkonrad
  • 83,997
  • 17
  • 205
  • 265
8

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.

Javamav
  • 153
  • 2
  • 6
3
textarea { 
   min-height: 100%;
}
CRABOLO
  • 8,605
  • 39
  • 41
  • 68
3

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%;
}
OlivMertens
  • 134
  • 5
2

You can use CSS:

textarea {
    height: 100%;
}

Relative to the top layer.

Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88
skozz
  • 2,662
  • 3
  • 26
  • 37
0

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;
}
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>
Rob
  • 26,989
  • 16
  • 82
  • 98
0

.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;
}