Skip to content

Instantly share code, notes, and snippets.

@jacricelli
Created November 1, 2019 04:03
Show Gist options
  • Save jacricelli/1eef279e7de7a736f3f7cb5d4a61adb4 to your computer and use it in GitHub Desktop.
Save jacricelli/1eef279e7de7a736f3f7cb5d4a61adb4 to your computer and use it in GitHub Desktop.
Bootstrap list-group-items as checkboxes and radio buttons (using pure CSS)
// https://codepen.io/lehonti/pen/OzoXVa
.list-group-item {
user-select: none;
border-left: none;
border-right: none;
border-color: rgba(0, 0, 0, .05);
}
.list-group {
height: 400px;
overflow-y: scroll;
border-top: 1px solid rgba(0, 0, 0, .125);
border-bottom: 1px solid rgba(0, 0, 0, .125);
label:first-of-type {
border-top: none;
}
label:last-of-type {
border-bottom: none;
}
input[type='checkbox'] {
display: none;
& + .list-group-item {
cursor: pointer;
&:before {
content: '\2713';
color: transparent;
font-weight: bold;
margin-right: 1em;
}
}
&:checked {
& + .list-group-item {
background-color: #0275d8;
color: #fff;
&:before {
color: inherit;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment