gpt4 book ai didi

css - 以更简单的方式单选点击文本

转载 作者:太空宇宙 更新时间:2023-11-04 13:38:51 28 4
gpt4 key购买 nike

enter image description here

我使用了一个主题,它可以提供一个漂亮的 UI

代码有点脏,因为我需要为每个输入指定一个唯一的 id,

还有其他方法吗?

我用Haml写的

%input.ace{id: "radio_field_1", name: "radio_field[]", type: "radio", value: "1"}/
%label.lbl{for: "radio_field_1"}
radio option 1

%input.ace{id: "radio_field_2",name: "radio_field[]", type: "radio", value: "2"}/
%label.lbl{for: "radio_field_2"} radio option 2

%input.ace{id: "radio_field_3",name: "radio_field[]", type: "radio", value: "3"}/
%label.lbl{for: "radio_field_3"} radio option 3

HTML 输出

<input class="ace" id="radio_field_1" name="radio_field[]" type="radio" value="1">
<label class="lbl" for="radio_field_1">
radio option 1
</label>

最佳答案

你应该使用 rails form helper ,而不是纯 HTML,来创建您的表单:

- form_tag "/some_path" do
- 3..times do |i|
= radio_button_tag 'radio_field', i, id: "radio_field_#{i}"
= label_tag 'radio_field, 'radio button #{i}'

这应该有效 - 如果无效,将会有进一步的帮助

关于css - 以更简单的方式单选点击文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22832413/

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