Skip to content

Instantly share code, notes, and snippets.

@thelamina
Created August 26, 2020 07:28
Show Gist options
  • Save thelamina/9869ac9134e60a095ddc665a724d7244 to your computer and use it in GitHub Desktop.
Save thelamina/9869ac9134e60a095ddc665a724d7244 to your computer and use it in GitHub Desktop.
style radio, checkbox as a button
<div>
<div class='ck-button'>
<label>
<input
type='radio'
name='size'
defaultChecked
defaultValue={product.size8}
/>
<span>size 8</span>
</label>
</div>
<div class='ck-button'>
<label>
<input
type='radio'
name='size'
defaultValue={product.size10}
/>
<span>size 10</span>
</label>
</div>
<div class='ck-button'>
<label>
<input
type='radio'
name='size'
defaultValue={product.size12}
/>
<span>size 12</span>
</label>
</div>
</div>
.ck-button{
margin: 4px;
margin-top: 0;
background-color: #fff;
border-radius: 4px;
border: 1px solid #f24472;
overflow: auto;
float: left;
}
.ck-button:hover {
background: #f2447257;
}
.ck-button label {
cursor: pointer;
float: left;
font-size: 16px;
width: auto;
}
.ck-button label span {
text-align: center;
padding: 3px 0px;
display: block;
padding: 4px 10px;
}
.ck-button label input {
position: absolute;
top: -20px;
}
.ck-button input:checked + span {
padding: 4px 10px;
background-color: #f24472;
color: #fff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment