This is miserably mysterious. I have a form with a textarea field. I've removed decorators and all that, and I setAttribs
with rows and cols (developing in Zend Framework). The textarea continues to be extremely wide, spilling out of its container and outside the viewport. I can add a screenshot if necessary.
Here's the basic code:
<form id="edit-pending-email" enctype="application/x-www-form-urlencoded" method="post" action="[path]/email/edit-pending-email/">
<label for="salutation" class="optional">Salutation</label>
<input type="text" name="salutation" id="salutation" value="Yo" /> <p><label for="content" class="optional">Body of Email</label>
<textarea name="content" id="content" cols="40" rows="30"> blah blah ... text goes here ...
</textarea></p>
<input type="submit" name="save" id="save" value="Save" />
<input type="submit" name="cancel" id="cancel" value="Cancel" /></form>
Here are the oddities.
I have looked in the CSS (it shouldn't matter, but I checked) and there's no reference to cols and the only width references are to other elements. In short, there is absolutely no reason why the cols setting is behaving the way it is.
And yet, it is.
After setting width: auto
, the cols attribute works for me (at least in Chrome, I didn't test other browsers yet).
textarea {
width: auto;
}
I finally tracked this one down. It was indeed in the stylesheet. That is, it wasn't in the stylesheet, but should have been.
Turns out, for reasons I do not understand, a textarea (applies to other elements too) wants to expand to its maximum, regardless of what cols says. This makes no sense to me but there it is.
The way to fix this is to set max-width. As soon as I did that, the element behaved and sized to the proper width. Note: width doesn't do it. Only max-width works.
Geez.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With