HTML.haml中的复选框列表(List of checkboxes in HTML.haml)

我一直在使用ruby on rails上的应用程序并尝试显示这样的复选框列表 []冲突决议

[]客户知道如何

[ ] 个人品牌

但我设法得到了这个

解决冲突

[]

客户知道如何

[]

个人品牌

[]

我的html.haml文件看起来像这样

.col-md-6.col-md-offset-3 = form_for(@user) do |f| = f.label :conflict_resolution, 'Conflict Resolution' = f.check_box :conflict_resolution = f.label :customer_know_how, 'Customer Know How' = f.check_box :customer_know_how = f.label :personal_branding, 'Personal Branding' = f.check_box :personal_branding

尝试显示:输入type =复选框内联。 没锻炼!!

I've been working on an application in ruby on rails and trying to display list of check boxes like this [ ] Conflict Resolutions

[ ] Customer Know how

[ ] personal Branding

But I managed to get this

Conflict Resolution

[ ]

Customer Know How

[ ]

Personal Branding

[ ]

My html.haml file looks like this

.col-md-6.col-md-offset-3 = form_for(@user) do |f| = f.label :conflict_resolution, 'Conflict Resolution' = f.check_box :conflict_resolution = f.label :customer_know_how, 'Customer Know How' = f.check_box :customer_know_how = f.label :personal_branding, 'Personal Branding' = f.check_box :personal_branding

Tried Display:inline for inputtype = checkbox . Didn't work out!!

最满意答案

使用

input[type='checkbox'] { display: block; float: left; } input[type='checkbox'] + label { display: block; }

如果您不希望这会影响复选框的可视化表示以及应用程序其他部分上的后续标签(使用相同的css),则需要通过在两个规则之前使用与其父级匹配的选择器为规则提供一些html上下文(与应用程序的其他页面/部分上的所有其他父项不同)。

Use

input[type='checkbox'] { display: block; float: left; } input[type='checkbox'] + label { display: block; }

If you don't want this to affect the visual representation of checkboxes and following labels on other parts of your application (that uses the same css), you need to give the rule some html context by preceding both rules with a selector matching it's parent (that is different from all other parents on other pages/parts of the application).

更多推荐