html - 为什么 Django forms.TextField 占用这么多空间,即使文本输入区域很小?

标签 html css django

我正在创建 Django 表单,当我从 TextInput 更改为 TextArea 时,html/css 需要在元素周围留出更多间距,这里是 TextArea: enter image description here

这里有一个 TextInput:

enter image description here

我正在使用 Bulma css 框架。并且我尝试使 TextField“适合”以使用可用区域的所有操作都失败了。 bulma 列有 display: flex,也不能修改。

如何在保持“紧凑”布局的同时使用文本区域?

编辑:将固定高度放在 div 上可行,但随后它失去了所有责任,并且布局不起作用。

最佳答案

基本上

 The <input> tag specifies an input field where the user can enter data. 

 and

 The <textarea> tag defines a multi-line text input control.

这是基本的区别,也是它占用大量空间的原因

你可以试试这个

 class MyForm(forms.ModelForm):
    class Meta:
    model = MyModel
     widgets = {
          'yourtextarea': forms.Textarea(attrs={'rows':4, 'cols':15}),
        }

关于html - 为什么 Django forms.TextField 占用这么多空间,即使文本输入区域很小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55194869/

相关文章:

python - Django:返回渲染可哈希错误

javascript - 如何将 Javascript 生成的文本包含到 HTML div 中并定义字体、大小等?

html - 将样式应用于标签时使样式覆盖另一种样式

html - 如何从一页中删除 Wordpress 标题?

html - 如何在内容页面中固定高度 100%? CSS 和分区

php - 通过 javascript 添加金额的 onclick 函数

jquery - .html() 和 .load() 之间的区别

javascript - 如何在 JavaScript 中提交后更改 URL 中的参数

python - 根据 DateTimeField 从数据库中自动删除 Django 对象

python - 如何在python中遍历httprequest post变量