Skip to content

Instantly share code, notes, and snippets.

@duplaja
Last active July 18, 2019 00:39
Show Gist options
  • Save duplaja/3a499a37c41579c9e711cf79fbb29baf to your computer and use it in GitHub Desktop.
Save duplaja/3a499a37c41579c9e711cf79fbb29baf to your computer and use it in GitHub Desktop.
Checkbox Toggle for Gravity Forms: Use Class .pt-toggle
.gform_wrapper .pt-toggle .gfield_checkbox input[type=checkbox] {
margin-left: -9999px;
position: absolute;
visibility: hidden;
}
.gform_wrapper .pt-toggle .gfield_checkbox input[type=checkbox] + label {
background-color: #ddd;
border-radius: 60px;
cursor: pointer;
display: block;
padding: 4px;
outline: none;
position: relative;
transition: background 0.4s;
user-select: none;
width: 64px;
height: 32px;
}
.gform_wrapper .pt-toggle .gfield_checkbox input[type=checkbox] + label::before, .gform_wrapper .pt-toggle .gfield_checkbox input[type=checkbox] + label::after {
content: '';
display: block;
position: absolute;
}
.gform_wrapper .pt-toggle .gfield_checkbox input[type=checkbox] + label::before {
background-color: #ddd;
border-radius: 60px;
top: 0;
right: 0;
bottom: 0;
left: 0;
transition: background 0.4s;
}
.gform_wrapper .pt-toggle .gfield_checkbox input[type=checkbox] + label::after {
background-color: #fff;
border-radius: 60px;
color: #fff;
line-height: 24px;
top: 4px;
bottom: 4px;
left: 4px;
width: 24px;
text-align: center;
transition: margin 0.4s, background 0.4s;
}
.gform_wrapper .pt-toggle .gfield_checkbox input[type=checkbox]:checked + label {
background-color: #5cb85c;
}
.gform_wrapper .pt-toggle .gfield_checkbox input[type=checkbox]:checked + label::before {
background-color: #5cb85c;
}
.gform_wrapper .pt-toggle .gfield_checkbox input[type=checkbox]:checked + label::after {
background-color: #fff;
color: #5cb85c;
margin-left: 32px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment