在项目中遇到 修改 input选中后的背景颜色
实现效果如下图:
代码如下:
通过 after 伪类选择器 实现
<style>input[type=checkbox] {cursor: pointer;position: relative;width: 15px;height: 15px;font-size: 14px;}input[type=checkbox]::after {position: absolute;top: 0;color: #000;width: 15px;height: 15px;display: inline-block;visibility: visible;padding-left: 0px;text-align: center;content: ' ';border-radius: 3px}input[type=checkbox]:checked::after {content: "✓";color: #fff;font-size: 12px;font-weight: bold;background-color: #ff366f;}</style>