views:

52

answers:

1

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.

+3  A: 

<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.

Krevan
Thank you very much!
john
+1 I never realized that you need those attributes in order to make `width:100%` work. I used some other work around to automatically resize the textarea if its parent container is resized but now it is so much easier :) Thank you!
Felix Kling