I've made a fancy checkbox, which uses pseudo-elements to look nice, but unfortunately the overflow: hidden
doesn't work well in its case. I don't know why.
Here's my code:
.wrapper {
background: black;
}
.priority {
display: none;
}
.priority, .priority:after, .priority:before, .priority *, .priority *:after, .priority *:before, .priority + .priority-btn {
box-sizing: border-box;
}
.priority + .priority-btn {
overflow: hidden;
backface-visibility: hidden;
transition: all 0.2s ease;
background: #666;
width: 100%;
border-radius: 0.25rem;
padding: .375rem .75rem;
height: 2.375em;
}
.priority + .priority-btn::after, .priority + .priority-btn::before {
display: inline-block;
transition: all 0.2s ease;
width: 100%;
text-align: center;
position: absolute;
font-weight: bold;
color: #fff;
}
.priority + .priority-btn::after {
left: 100%;
content: 'IMPORTANT';
}
.priority + .priority-btn::before {
left: 0;
content: 'UNIMPORTANT';
}
.priority + .priority-btn:active {
background: #888;
}
.priority + .priority-btn:active::before {
left: -10%;
}
.priority:checked + .priority-btn {
background: #86d993;
}
.priority:checked + .priority-btn:before {
left: -100%;
}
.priority:checked + .priority-btn:after {
left: 0;
}
.priority:checked + .priority-btn:active:after {
left: 10%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="wrapper">
<div class="container">
<div class="row">
<div class="col">
<input type="checkbox" ngModel name="priority" id="priority" class="priority">
<label class="priority-btn" for="priority"></label>
</div>
</div>
</div>
</div>
As you can see the text comes out from the container label.