Skip to content

Instantly share code, notes, and snippets.

@79man
Last active November 20, 2015 16:08
Show Gist options
  • Save 79man/a44fdb28863f8908eb8f to your computer and use it in GitHub Desktop.
Save 79man/a44fdb28863f8908eb8f to your computer and use it in GitHub Desktop.
Material Design (Radio Button, CheckBox)
<body>
<form>
<div class="md-radio">
<input id="male" type="radio" name="radio-group" class="md-radio-input" />
<label for="male" class="md-input-label">Male</label>
<input id="female" type="radio" name="radio-group" class="md-radio-input" />
<label for="female" class="md-input-label">Female </label>
</div>
<br/>
<div class="md-radio">
<input type="checkbox" name="checkme" id="checkme" class="md-check-input" />
<label for="checkme" class="md-input-label">Check me!</label>
<input type="checkbox" name="checkme2" id="checkme2" class="md-check-input" />
<label for="checkme2" class="md-input-label">Check me 2!</label>
</div>
</form>
</body>
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
background: #ececec;
}
form {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
/* ------------------------- Separate line ------------------------- */
.md-radio {
border-left: 0.2em solid #309050;
line-height: 2em;
}
.md-radio-input,
.md-check-input {
margin: 0.5em;
}
.md-radio-input::before,
.md-check-input::before {
border: 3px solid #309050;
border-radius: 100%;
content: "";
cursor: pointer;
width: 15px;
height: 15px;
position: absolute;
transition: all 0.3s ease-in-out;
}
.md-check-input::before {
border-radius: 10%;
}
.md-radio-input::after,
.md-check-input::after {
background: #ececec;
content: "";
display: block;
height: 15px;
}
.md-radio-input:checked::before,
.md-check-input:checked::before {
transform: scale(1.5);
//background-color: #309050;
background-color: #60c080;
}
.md-radio-input:hover::before,
.md-check-input:hover::before {
transform: scale(1.5);
//background-color: #60c080;
}
.md-input-label {
cursor: pointer;
color: #309050;
}
.md-radio input[type="radio"]:checked + label {
border-bottom: 0.2em solid #309050;
//border-top: 0.1em dotted #309050;
}
/*
.md-radio input[type="checkbox"]:checked + label {
border-bottom: 0.2em solid #309050;
//border-top: 0.1em dotted #309050;
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment