Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 将css样式从网站调整为Django crispy表单复选框_Html_Css - Fatal编程技术网

Html 将css样式从网站调整为Django crispy表单复选框

Html 将css样式从网站调整为Django crispy表单复选框,html,css,Html,Css,我使用的是bootstrap,我有一个Django crispy表单,表单中有一个复选框,html如下所示: <div class="form-group"> <div class="checkbox" id="div_id_include"> <label class="" for="id_include"><input class="checkboxinput" id="id_include" name

我使用的是bootstrap,我有一个Django crispy表单,表单中有一个复选框,html如下所示:

    <div class="form-group">
        <div class="checkbox" id="div_id_include">
            <label class="" for="id_include"><input class="checkboxinput" id="id_include" name="include" type="checkbox"> Include some data.</label>
        </div>
    </div>
样式来自这里:(在这里您还可以看到复选框的示例)。

如果在我不使用Crispy表单但直接输出html(在表行中)的情况下,此功能正常工作:


好吧,没有懒惰的方法可以做到这一点。我通过确保遵循我在帖子中引用的嵌入式应用程序css提供的html布局,然后为复选框定制crispy forms字段模板,以确保它以正确的布局呈现html,从而解决了这个问题:

<div class="input-wrapper inline">
  <div class="checkbox-wrapper"><input class="checkbox" type="checkbox" id="check1" name="check1" value=""><span class="checkbox-styled"></span></div>
  <label for="check1">Check 1</label>
</div>

检查1

您可以控制Crispy输出吗?控制非常有限,我可以将整个表单组包装在一个div中,或者为input checkboxinput包含一个css_类。或者,从技术上讲,我可以编写自己的模板,以特定的方式格式化表单字段(我以前从未尝试过)。但事实上,我并不擅长应用css,甚至在将css应用到默认引导复选框(没有我的表单布局)时都遇到了麻烦。
<td>
    <div class="checkbox-wrapper"><input class="checkbox" type="checkbox" id="id" name="" value="id"><span class="checkbox-styled"></span></div>
</td>
<div class="input-wrapper inline">
  <div class="checkbox-wrapper"><input class="checkbox" type="checkbox" id="check1" name="check1" value=""><span class="checkbox-styled"></span></div>
  <label for="check1">Check 1</label>
</div>