我找到了解决问题的一些代码,但是所有这些代码都使用了彼此靠近的输入标签和标签标签。 Django在标签内部放置了输入,这就是为什么代码在我的情况下是无效的。 我试过的变体之一here 任何建议或想法。 谢谢大家!
input[type=radio] {
display:none;
}
input[type=radio] + label
{
background: #999;
height: 16px;
width: 16px;
display:inline-block;
padding: 0 0 0 0px;
}
input[type=radio]:checked + label
{
background: #0080FF;
height: 16px;
width: 16px;
display:inline-block;
padding: 0 0 0 0px;
}
答案 0 :(得分:0)
解决了问题自定义表单模板并在上面的css上应用了解决方案。
{% for field in form %}
{% for item in field %}
<input id="id_name_{{ forloop.counter0 }}" name="name" type="radio" value="{{ item.choice_value }}">
<label for="id_name_{{ forloop.counter0 }}">{{ item.choice_label }}</label>
{% endfor %}
{% endfor %}
答案 1 :(得分:0)