我想将 textarea
的高度设置为100%。 我正在使用 Bootstrap 3,但在那里找不到选项。
<div class="container">
<textarea class="form-control" rows="8"></textarea>
</div>
如何做?
我想将 textarea
的高度设置为100%。 我正在使用 Bootstrap 3,但在那里找不到选项。
<div class="container">
<textarea class="form-control" rows="8"></textarea>
</div>
如何做?
html, body, .container {
height: 100%;
}
textarea.form-control {
height: 100%;
}
我认为这是一个bootstrap问题。我曾遇到过类似的问题,其中textarea不允许超过1行。通过试错,我发现将textarea放置在一个div中,并忽略第一个div内的form-group-(x)调用,我能够控制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>
<div class="form-group">
<textarea class="form-control" rows="8"></textarea>
</div>
对于Bootstrap 3,我的情况无法使用此方法。你可以尝试修改行数。
<textarea class="form-control" cols="60" rows="16"></textarea>
.form-group{
height:250px;
}
textarea{
height:100%;
}
<textarea class="form-control" cols="60" rows="16"></textarea>
这段代码是有效的。 - Mehmet Sefa Balıktextarea {
min-height: 100%;
}
textarea {
height: 100%;
}
block
。这是我的错。看一下 jsfiddle,我告诉过你,你需要先考虑主容器,例如 davidkonrad
。 - skozz这解决了我的问题.. 我将高度设置为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 {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 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>
这对我有用,我将它放在一个容器中
.textarea {
position: absolute;
height: 100%;
width: 100%;
}
.textarea .text {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
height: 100%
? - Zhihao