YeP
YeP

Reputation: 211

django form textarea allow vertical resize only

in my django project I made a form using

message = forms.CharField(widget=forms.Textarea)

It works out ok and I get this. The text area is resizeable both horizontally and vertically:

enter image description here

I would like to make it un-resizeable horizontally, what should I do? I tried adding "attrs=" to the textarea but can't figure out what to call... Please help... Thanks.

Upvotes: 0

Views: 730

Answers (1)

NS0
NS0

Reputation: 6096

I believe you can achieve this with a css rule:

resize: vertical;

So, one way is to give it a class

message = forms.CharField(widget=forms.TextArea(attrs={"class": "message"}))

Then define a css rule

.message{
    resize: vertical;
}

Upvotes: 2

Related Questions