如何使textarea填充其父宽度的宽度? [英] How to make textarea fill the width of its parent width?

查看:104
本文介绍了如何使textarea填充其父宽度的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为我们事先不知道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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆