css only checkbox (with content attribute)

前端 未结 4 507
再見小時候
再見小時候 2021-01-20 04:59

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, a

4条回答
  •  滥情空心
    2021-01-20 05:27

    Creating an actual element with CSS isn't possible. You can however style a checkbox using css.

    An example:

    input[type=checkbox] {
        outline: 2px solid #f00;
    }
    

    Relying on pure CSS is also a give-or-take when dealing with different browsers and platforms. I hope this answers your question.

提交回复
热议问题