【问题标题】:Django Template Condition with css带有 css 的 Django 模板条件
【发布时间】:2021-03-22 05:28:32
【问题描述】:

我的问题是:我想用 css 在 Django 模板中做一个条件,但它没有用。

<label>{% if not typ.required  %}
 {% trans 'Bitte Auswahl treffen' %}{% endif %}</label>
  <input type="checkbox"  {% if typ.required %} style="display:none;" checked="checked"
 {% endif %} name="checkbox"
 data-toggle="toggle" id="{{ typ.typ_id }}"
 value="{{ cookie_id }}" />

{% if typ.required %} style="display:none;" checked="checked"{% endif %}

checked="checked" 有效,但 Style 无效。

如果我按 f12 观看网站,我会在输入类型中看到这种风格

谢谢大家

【问题讨论】:

    标签: html css django django-templates


    【解决方案1】:

    我找到了解决方案。上面的 div 覆盖了复选框的样式 :-)

    【讨论】:

      猜你喜欢
      • 2018-01-14
      • 2019-07-03
      • 2014-08-02
      • 2011-10-03
      • 2017-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-06
      相关资源
      最近更新 更多