单选按钮上的标签颜色更改单击

时间:2019-07-25 11:19:14

标签: css ruby simple-form

enter image description here

我正在使用带有两个单选按钮的导轨中的简单表单。 当选中单选按钮/标签时,我希望单选按钮被隐藏并且标签更改颜色。 但是,我现在可以使它起作用的唯一方法是单选按钮是否可见,并且单击该按钮时,标签会更改颜色。 for和id对于单选按钮是相同的,所以这不是问题。 我不确定这个问题。谢谢

<div class="modal-flex">
        <%= f.radio_button "refund_#{invoice.id}", :credit_note, class: "radio-refund" %>
        <%= f.label "refund_#{invoice.id}_credit_note", t(".refund_credit_note"), class: "modal-options refund"%>
        <%= f.radio_button "refund_#{invoice.id}", :only, class: "radio-refund" %>
        <%= f.label "refund_#{invoice.id}_only", t(".refund_only"), class: "modal-options refund" %>
      </div>

  input[type="radio"] + label:before {
    display: none;
  }

 input[type="radio"]:checked + label:after {
    background-color: $color-gray
  }

1 个答案:

答案 0 :(得分:0)

用更多的scss修复。错误的语法