gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 06:24:32 24 4
gpt4 key购买 nike

我正在创建 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com