Html 你如何增加一个html文本框的高度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1152840/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how do you increase the height of an html textbox
提问by mrblah
How do you increase the height of an textbox? (along with its font size)
如何增加文本框的高度?(连同它的字体大小)
回答by Paul Dixon
I'm assuming from the way you worded the question that you want to change the size after the page has rendered?
我从您提出问题的方式中假设您想在页面呈现后更改大小?
In Javascript, you can manipulate DOM CSS properties, for example:
在 Javascript 中,您可以操作DOM CSS 属性,例如:
document.getElementById('textboxid').style.height="200px";
document.getElementById('textboxid').style.fontSize="14pt";
If you simply want to specify the height and font size, use CSS or style attributes, e.g.
如果您只想指定高度和字体大小,请使用 CSS 或样式属性,例如
//in your CSS file or <style> tag
#textboxid
{
height:200px;
font-size:14pt;
}
<!--in your HTML-->
<input id="textboxid" ...>
Or
或者
<input style="height:200px;font-size:14pt;" .....>
回答by Jan Aagaard
Note that if you want a multi line text box you have to use a <textarea>
instead of an <input type="text">
.
请注意,如果您想要一个多行文本框,您必须使用 a<textarea>
而不是<input type="text">
。
回答by Sam152
Increasing the font size on a text box will usually expand its size automatically.
增加文本框的字体大小通常会自动扩大其大小。
<input type="text" style="font-size:16pt;">
If you want to set a height that is not proportional to the font size, I would recommend using something like the following. This prevents browsers like IE from rendering the text inside at the top rather than vertically centered.
如果你想设置一个与字体大小不成比例的高度,我建议使用如下所示的内容。这可以防止 IE 等浏览器在顶部呈现文本而不是垂直居中。
.form-text{
padding:15px 0;
}
回答by user
<input type="text" style="font-size:xxpt;height:xxpx">
Just replace "xx" with whatever values you wish.
只需将“xx”替换为您想要的任何值。
回答by Janarthanan Ramu
With inline style:
<input type="text" style="font-size: 18pt; height: 40px; width:280px; ">
or with apart CSS:
HTML:
<input type="text" id="txtbox">
CSS:
#txtbox { font-size: 18pt; height: 42px; width : 300px; }
使用内联样式:
<input type="text" style="font-size: 18pt; height: 40px; width:280px; ">
或使用单独的 CSS:
HTML:
<input type="text" id="txtbox">
CSS:
#txtbox { font-size: 18pt; height: 42px; width : 300px; }
回答by Gayan Dasanayake
If you want multiple lines consider this:
如果您想要多行,请考虑:
<textarea rows="2"></textarea>
Specify rows as needed.
根据需要指定行。
回答by James
Use CSS:
使用 CSS:
<html>
<head>
<style>
.Large
{
font-size: 16pt;
height: 50px;
}
</style>
<body>
<input type="text" class="Large">
</body>
</html>