Created
March 23, 2018 10:34
-
-
Save aaronsummers/3a26476b35ebccae3e4ca0d79c2304b9 to your computer and use it in GitHub Desktop.
Custom checkbox style for contact form 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $('.wpcf7-acceptance label').on('click', function(event) { | |
| if($('input[type=checkbox]').attr('checked')) { | |
| $(this).toggleClass('checked'); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Editable region | |
| .wpcf7-form { | |
| .wpcf7-acceptance { | |
| label { | |
| &.checked:after { | |
| font-family: $icons; // using fontello's icons for the font family | |
| content: '\e802'; // icon font | |
| color: $red; // Color variable | |
| } | |
| } | |
| } | |
| // Default for checkbox | |
| .wpcf7-form { | |
| .wpcf7-acceptance { | |
| span.wpcf7-list-item { | |
| margin: 0; | |
| } | |
| label { | |
| &:before, | |
| &:after { | |
| content: ''; | |
| position: absolute; | |
| width: 20px; | |
| height: 20px; | |
| line-height: 20px; | |
| text-align: center; | |
| left: 0; | |
| top: 50%; | |
| transform: translateY(-50%); | |
| } | |
| &:before { | |
| border:2px solid $text_blue; | |
| border-radius: 2px; | |
| } | |
| input[type="checkbox"] { | |
| visibility: hidden; | |
| } | |
| position: relative; | |
| cursor: pointer; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using the forms acceptance on this example.
Should be easy to modify for other checkboxes as they'll use the same structure.