Reputation: 768
I need a way to resize a textarea
based on the width of the entire page. I have a div
absolutely positioned next to it with a width of 40%, and I want to have my textarea
take up the rest of the page. I know I can't just say <textarea width="60%"...>
because textarea
doesn't have a width
attribute. Is there any way to tell textarea
to take up a relative amount of space?
Upvotes: 2
Views: 8354
Reputation: 28753
Again, use CSS. But use external CSS:
#teh-div {
width:500px;
}
#teh-div textarea {
width:65%;
}
<div id="teh-div"><textarea ></textarea></div>
Upvotes: 1
Reputation: 66132
Textarea doesn't have a width element, but you can use CSS to define the width of a textarea. You can use the following code to do so.
<div style="width: 500px;"><textarea style="width: 65%;"></textarea></div>
In the above code, the div will be 500 px wide, and the text area will be 65% of the width of the div.
Upvotes: 0
Reputation: 3204
You can specify the textarea width using CSS. http://jsfiddle.net/stevelove/uFDB4/
Upvotes: 4
Reputation: 7032
Put it in another div. That's simple, and will work.
<div id="textareaWrapper" style="width:'60%'"><textarea>text</textarea></div>
Upvotes: 0