简体   繁体   English

如何分别设置文本区域的默认大小和最小大小?

[英]How do I set the default size of a textarea seperatly from the minimum size?

There are two ways to set the size of an HTML textarea- the rows and cols attributes in HTML, and the height and width properties in CSS. 有两种方法可以设置HTML文本区域的大小-HTML中的rowscols属性,以及CSS中的heightwidth属性。 Unfortunately, these set both the default size of the textarea when the page is first loaded, and also the minimum size that the user can obtain by resizing it on the page. 不幸的是,这些设置既设置了首次加载页面时文本区域的默认大小,又设置了用户在页面上调整大小可获得的最小大小。 How do I set different sizes for these? 如何为这些设置不同的尺寸?

You have to use min-width and min-height for your text area. 您必须在文本区域中使用min-width和min-height。

<textarea rows="4" cols="10" id="myTextArea">Welcome to StackOverflow</textarea>

In css use: 在CSS中使用:

#myTextArea {
    min-width: 50px;
    min-height: 60px; 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM