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

后端 未结 10 1156
滥情空心
滥情空心 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:16

    You can take advantage of CSS3 to do that, by hidding the by-default input radio button with CSS3 rules:

    .class-selector input{
        margin:0;padding:0;
        -webkit-appearance:none;
           -moz-appearance:none;
                appearance:none;
    }
    

    And then using labels for images as the following demos:

    JSFiddle Demo 1

    From top to bottom: Unfocused, MasterCard Selected, Visa Selected, Mastercard hovered

    JSFiddle Demo 2

    Visa selected

    Gist - How to use images for radio-buttons

提交回复
热议问题