如何增加文本框的高度?(以及它的字体大小)
根据您提问的措辞,我认为您想要在页面渲染后更改大小?
在Javascript中,您可以操作DOM CSS属性,例如:
document.getElementById('textboxid').style.height="200px";
document.getElementById('textboxid').style.fontSize="14pt";
如果你只是想指定高度和字体大小,可以使用CSS或样式属性,例如:
//in your CSS file or <style> tag
#textboxid
{
height:200px;
font-size:14pt;
}
<!--in your HTML-->
<input id="textboxid" ...>
或者<input style="height:200px;font-size:14pt;" .....>
<textarea>
而不是 <input type="text">
。将文本框的字体大小增加通常会自动扩大其大小。
<input type="text" style="font-size:16pt;">
如果您想设置与字体大小不成比例的高度,我建议使用以下代码。这可以防止像IE这样的浏览器将文本渲染在顶部而不是垂直居中。
.form-text{
padding:15px 0;
}
<input type="text" style="font-size:xxpt;height:xxpx">
只需将“xx”替换为您想要的任何值即可。
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;
}
如果您需要多行文本,请考虑以下方法:
<textarea rows="2"></textarea>
根据需要指定行。
<html>
<head>
<style>
.Large
{
font-size: 16pt;
height: 50px;
}
</style>
<body>
<input type="text" class="Large">
</body>
</html>