文章阅读

沉浸阅读完整内容

写文章

自定义checkbox样式

正在统计阅读人数 正在统计字数
登录收藏0
字号 100%

效果图:
自定义checkbox样式


自定义checkbox样式

HTML

<div class="list">
            <label><input type="checkbox">旅游</label>
            <label><input type="checkbox">娱乐</label>
            <label><input type="checkbox">学习</label>
            <label><input type="checkbox">打篮球</label>
        </div>

CSS

    .list {
                user-select: none;
                margin-top: 10px;
                text-align: center;
                height: 20px;
            }

            .list input {
                margin: 0 5px;
                /* 相对定位 */
                position: relative;
            }

            .list input::after {
                content: "";
                width: 18px;
                height: 18px;
                background-color: #8b8b8b;
                /* 绝对定位 */
                position: absolute;
                /* 圆 */
                border-radius: 50%;
                top: -3px;
                left: -3px;
            }

            .list input::before {
                position: absolute;
                content: "√";
                z-index: 2;
            }

            .list input:checked::after {
                background-color: red;
            }

            .list input:checked::before {
                color: #fff;
            }

推荐阅读

4 篇精选
文章 / 181饿了么表格组件 文章 / 182Vue3中判断对象中是否存在指定参数 文章 / 179小程序入门教程 文章 / 180数组如何递归降维

发表评论

评论 0

还没有评论,欢迎留下第一条讨论。

分享精彩,传递价值

生成专属海报,分享你的文章,让更多人发现好内容

浏览器不支持 Canvas,无法生成海报。

每日签到

每天来这里,记录一点持续积累。

当前积分--积分
本月签到--
本月获得--积分
正在读取