[英]Textarea having always window height
我不知道該怎么做。 我現在正在使用Bootstrap的textarea及其容器。 我不知道如何制作它以便textarea延伸到屏幕的底部,根據窗口高度自動增加/減少。 我試過了:
#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;
}
如果它不起作用,請嘗試!important。 如果它也不起作用,請嘗試在標記中設置行並在CSS上設置line-height。
<textarea rows="4">
.form-control
應該是bootstrap的CSS類。
你在使用<textarea class="form-control"></textarea>
嗎? 如果是這樣,您的css規則使用#
,它對應於元素ID,而不是類。 將CSS更改為:
.form-control {
position:fixed;
top:0;
left:0;
right:0;
bottom:0;
}
試試這個代碼。 實際上你已經使用了(id)#form-control,它應該是(class).form-control我已經使用了你的代碼,只是增加了寬度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%;
}
就像幾個例子。
我建議您在高度css屬性上查看這個 W3 Schools頁面...如果您閱讀該頁面,您可以看到您還可以調整其大小。
在該頁面上還有一個指向此演示的鏈接,我建議您嘗試查看缺少更好單詞的不同“設置”。
還要確保開頭的<textarea>
標簽調用選擇器 ...所以它應該看起來像這樣<textarea id="form-control">
。
祝好運
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.