gpt4 book ai didi

css - 香脆形式 : add css class for one of the inputs

转载 作者:技术小花猫 更新时间:2023-10-29 10:32:53 26 4
gpt4 key购买 nike

在我的 forms.py 我有

[...]
self.helper.layout = Layout(
Field('name'),
Field('description'),
)
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-md-2 col-xs-3'
self.helper.field_class = 'col-md-10 col-xs-9'
[...]

呈现给

<div id="div_id_name" class="form-group">
<label class="control-label col-md-2 col-xs-3 requiredField" for="id_name">
Name
</label
<div class="controls col-md-10 col-xs-9">
<input id="id_name" class="textinput textInput form-control" type="text" name="name" maxlength="20">
</div>
</div>
<div id="div_id_description" class="form-group">
<label class="control-label col-md-2 col-xs-3 requiredField" for="id_description">
Description
</label>
<div class="controls col-md-10 col-xs-9">
<textarea id="id_description" class="textarea form-control" rows="10" name="description" cols="40"></textarea>
</div>
</div>

现在我希望只是名称输入更小,像这样:

[...]
<div class="controls col-md-8 col-xs-7">
<input id="id_name" class="textinput textInput form-control" type="text" name="name" maxlength="20">
</div>
</div>
[...]

(如何)这可以在 crispy-forms 中实现?

最佳答案

给你的布局助手:

self.helper.layout = Layout(
Field('name'),
Field('description'),

添加css_class:

Field('field_name', css_class="controls col-md-8 col-xs-7")

这是文档 link

关于css - 香脆形式 : add css class for one of the inputs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24812267/

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