【发布时间】:2015-03-11 10:27:11
【问题描述】:
我一直在尝试为表单上的一些单选按钮设置样式,但自从设置了样式后,我似乎无法选择它们...
我的 CSS 是:
.radio-toolbar input[type="radio"] {
display: none;
margin: 10px;
// text-align: center;
}
.radio-toolbar label {
display: inline-block;
background-color: transparent;
border-style: solid;
border-width: 1px;
border-color: white;
padding: 8px 50px;
color: white;
}
.radio-toolbar input[type="radio"]:checked + label {
background-color: white;
color: gray;
}
单选按钮是 (HAML):
.form-group
.col-sm-10.radio-toolbar
- YearGroup.all.each do |year_group|
= f.radio_button(:year_group_id, year_group.id)
= label_tag dom_id(year_group), year_group.name
= f.label :year_group
关于为什么我不能选择它们的任何想法?
【问题讨论】:
-
我不知道标签是否设置了
for属性,因为我不熟悉HAML,但这可能是原因 -
我不确定你的意思?我从这里得到了 CSS:stackoverflow.com/a/4642152/4262212
-
您渲染的标签是否具有
for属性,例如<label **for="radio1"**>? -
是的,它是