如何使textarea填充其父宽度的宽度? [英] How to make textarea fill the width of its parent width?
问题描述
因为我们事先不知道div的宽度?
我的想法:用JS计算div的宽度,找到一种方法将其转换为col和应用css到textarea在飞行。
div>
< textarea style =width:100%>
*在大多数情况下都可以使用。
如果没有,请提供更多信息!
*注意:由于某种原因,它需要
和 rows
属性进行验证。但是设置宽度或高度将覆盖它们,因此可以输入任意值。
Given that we don't know the div's width beforehand?
My idea: Calculate the div 's width with JS, find a way to convert it to cols and the apply the css to the textarea onthe fly. But perhaps there 's no need to reinvent the wheel?
Thank you.
<textarea style="width:100%">
* will work in most cases.
If it doesn't, please provide more information!
* Note: for some reason, it will need the cols
and rows
attributes to validate. But setting a width or a height will override them, so put any value you want.
这篇关于如何使textarea填充其父宽度的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!