css only checkbox (with content attribute)
checkbox, css, html
Solution
input[type=checkbox] {
position: relative;
visibility: hidden;
cursor: pointer;
}
input[type=checkbox]:after {
display: block;
content: "OFF";
position: absolute;
top: 0;
right: -30px;
visibility: visible;
height: 30px;
line-height: 30px;
width: 50px;
text-align: center;
border-radius: 4px;
background: #d00;
color: #fff;
font-weight: 600;
cursor: pointer;
}
input[type=checkbox]:checked:after {
content: "ON";
background: #0a0;
}
<input type="checkbox" />
Problem
how can I make a custom checkbox with css only (no JS no JQ) with content:"on" when checked and content:"off" when uncheked. Thanks. reedit OK, after LOT of copy/paste/delete, it work now. Thank.