<header>
<h1>Custom Radio buttons</h1>
</header>
<form class="cb">
<div class="cb__item">
<input id="option_1" class="cb__input" type="radio" name="cb">
<label for="option_1" class="cb__label">Option</label>
</div>
<div class="cb__item">
<input id="option_2" class="cb__input" type="radio" name="cb">
<label for="option_2" class="cb__label">Option</label>
</div>
<div class="cb__item">
<input id="option_3" class="cb__input" type="radio" name="cb">
<label for="option_3" class="cb__label">Option</label>
</div>
</form>
@import "bourbon";
@import url(https://fonts.googleapis.com/css?family=Noto+Sans:400,700|Lobster);
$background: #FFEBAF;
$primary: #FF608B;
$secondary: #B73E47;
//$tertiary: #B73E47;
$white: #fff;
$break1: 55em;
$break2: 75em;
$break3: 90em;
@mixin break($val) {
@media (min-width: $val) {
@content;
}
}
* {
box-sizing: border-box;
}
body {
background: $background;
padding: 3em;
}
header {
text-align: center;
padding-bottom: 3em;
}
h1 {
font-family: 'Lobster', cursive;
font-size: 3.75em;
color: $secondary;
text-shadow: 0 2px lighten($secondary, 30%), 0 3px lighten($secondary, 30%), 0 4px lighten($secondary, 45%);
margin: 0;
}
@keyframes check {
0% {
transform: scale(1);
}
45% {
transform: scale(1.02);
}
75% {
transform: scale(1);
}
} // End animation
.cb {
$source: 'cb';
width: 406px;
margin: 0 auto;
@include clearfix;
&__item {
float: left;
margin-right: 2em;
&:last-child {
margin-right: 0;
}
} // End item
&__input {
display: none;
+ label {
&:before {
content:"☐";
font-size: 8rem;
position: absolute;
top: -5rem;
color: $secondary;
line-height: 0;
transition: all .7s ease;
}
}
&:checked {
+ label {
background: $primary;
color: $white;
box-shadow: 2px 2px 0 1px darken($primary, 10%);
&:before {
content: "☑";
color: $primary;
animation: check .6s 1;
}
&:after {
border-bottom-color: $primary;
}
} // End label
} // End checked
} // End input
&__label {
position: relative;
display: block;
background:url("https://raw.githubusercontent.com/thoughtbot/refills/master/source/images/textures/inverted/lghtmesh.png") #B73E47 scroll;
border-radius: .25em;
padding: 1em 2.25em;
margin-top: 10em;
font-size: .8em;
color: $white;
text-transform: uppercase;
text-align: center;
cursor: pointer;
box-shadow: 2px 2px 0 1px darken($secondary, 15%);
text-shadow: 0 1px rgba(255,255,255,.1);
letter-spacing: 1px;
&:before {
content: "";
position: absolute;
top: -10em;
left: 0;
width: 100%;
height: 8em;
}
&:after {
content: "";
position: absolute;
top: -10px;
left: 0;
right: 0;
margin: 0 auto;
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid $secondary;
}
}
}
View Compiled
This Pen doesn't use any external CSS resources.