How do I style radio buttons with images - laughing smiley for good, sad smiley for bad?

后端 未结 10 1162
滥情空心
滥情空心 2020-11-30 19:56

I would like to create an HTML form for user feedback. If the overall feedback is good, the user should click on a laughing smiley, if the overall feedback is bad, the user

10条回答
  •  长情又很酷
    2020-11-30 20:20

    Here's a pure HTML+CSS solution.

    HTML:

    SCSS:

      // use an image instead of the native radio widget
    .image-radio {   
      input[type=radio] {
        display: none;
      }
      input[type=radio] + label {
        background: asset-url('icons/choice-unchecked.svg') no-repeat left;
        padding-left: 2rem;
      }
      input[type=radio]:checked + label {
        background: asset-url('icons/choice-checked.svg') no-repeat left;
      }
    }
    

提交回复
热议问题