始终具有窗口高度的文本区域

Textarea having always window height

本文关键字:文本 区域 高度 窗口      更新时间:2023-09-26

我不知道该怎么做。我目前正在使用Bootstrap的文本区域及其容器。我不知道如何使文本区域延伸到屏幕底部,根据窗口高度自动增加/减少。我试过:

#form-control {
    position:fixed;
    top:0;
    left:0;
    right:0;
    bottom:0;
}

但似乎什么都没有改变。有人知道我该怎么做吗?

编辑:

这是我的html文件:

<body>
    <div class="container">
        <div class="form-group">
            <textarea class="form-control" rows="15" id="note"></textarea>
        </div>
    </div>
</body>

您必须像下面的代码一样在元素上放置height属性。

#form-control {
    position:fixed;
    top:0;
    left:0;
    right:0;
    bottom:0;
    height:50px;
}

如果它不起作用,试试!重要的如果它也不起作用,可以尝试在标记中设置行,并在CSS上设置行高。

<textarea rows="4">

.form-control应该是用于引导的CSS类。

您正在使用<textarea class="form-control"></textarea>吗?如果是这样,那么css规则使用的是#,它对应于一个元素ID,而不是一个类。将您的CSS更改为:

.form-control {
    position:fixed;
    top:0;
    left:0;
    right:0;
    bottom:0;
}

试试这个代码。实际上,您已经使用了(id)#form控件,它应该是(class).form控件我使用了你的代码,只是增加了宽度100%现在它需要屏幕的高度和宽度。

.form-control {
    position:fixed;
    top:0;
    left:0;
    right:0;
    bottom:0;
    width:100%
}
<div class="form-group">
  <textarea class="form-control" placeholder="textarea"></textarea>
</div>

您可以使用height属性将其设置为某个高度。

你可以这样做:

#form-control {
position:fixed;
height: 200px;
}

#form-control {
position:fixed;
height: 50%;
}

仅举几个例子。

我建议你查看这个W3学校页面的高度css属性。。。如果你阅读页面,你可以看到你可以如何调整它的大小。

在这个页面上还有一个链接到这个演示,我建议你试着看看不同的"设置"是什么,因为没有更好的词做

还要确保打开的<textarea>标记调用选择器。。。所以它应该看起来像这个CCD_ 6。

好运