django - 覆盖 Crispy Forms 的 Fieldset 中的标签偏移量
问题描述
我的布局中有一个 Fieldset,它在第一行包含一个复选框。对于我设置的主要形式:
self.helper.layout_class = "create-label col-md-2"
它对齐我的标签和字段并创建一个“偶数”表单。
问题是,这被应用在一个字段集中,一个复选框被打乱到右边,描述在右边,看起来它只是挂在屏幕中间:
这是因为生成的 html 正在应用为标签生成的偏移量,最终看起来像这样:
<div class="form-group row">
<div class="offset-md-2 col-md-10">
<div id="div_id_allow_invitees_to_add_others" class="custom-control custom-checkbox">
<input type="checkbox" name="allow_invitees_to_add_others" class="checkboxinput custom-control-input" id="id_allow_invitees_to_add_others">
<label for="id_allow_invitees_to_add_others" class="custom-control-label">
Allow invitees to add others
</label>
如果我手动删除offset-md-2
浏览器检查器中Fieldset
的 Div
那一点布局相当简单:
Div(
Fieldset(
_("Invitees"),
Field("allow_invitees_to_add_others"),
Formset("invitees"),
),
css_class="",
),
任何人都可以告诉我如何让这个复选框在左边!
解决方案
推荐阅读
- javascript - CSS 和 JS 高度从未设置到某个值的过渡
- java - 有没有办法在后台服务中刷新 android WebView?
- git - 在 gitlab 或 git 命令行中,如何跟踪 master 分支提交来自哪个合并请求?
- r - 决策树中 R 数据挖掘的空结果
- java - 什么是通知频道?
- sql-server - 替换 SQL 问题中的字符串
- javascript - 每次动态输入Jquery的增加按钮时如何从选择框中给出值
- websocket - grizzly websocket 中的背压支持
- sql - 查询订购所有类型产品的商店
- python - 如何返回熊猫数据框而不是系列