How to Style CSS Checkboxes with Font Awesome

后端 未结 3 1505
温柔的废话
温柔的废话 2020-12-17 18:57

I am trying to style my checkboxes with Font Awesome, the checkboxes are auto generated from a plugin I\"m using with wordpress I have a mockup of what everything looks like

3条回答
  •  感动是毒
    2020-12-17 19:11

    Ok, that CSS you have won't work because its wrong.

    Why? Because when you say "input + label", you should have an HTML markup like the one below:

    
     //You will be querying this label css with input + label
    

    See, is placed immediately after . You can confirm this HERE

    Now in your case, your was a child of you , looking like this:

    
    

    To query that, you could have done something like this:

    label>input[type=checkbox] {
    
    }
    label>input[type=checkbox]:checked {
    
    }
    

    And since you wanted to put something beetwen them, you add this to your css:

    label>input[type=checkbox]:before {
    
    }
    label>input[type=checkbox]:checked:before {
    
    }
    

    I've adjusted it for you. It's not the easiest/cutest way to implement it, but at least works with your current HTML.

    Here's the FIDDLE

提交回复
热议问题