温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

纯css如何实现选框选中效果

发布时间:2020-11-10 10:25:57 来源:亿速云 阅读:555 作者:小新 栏目:web开发

小编给大家分享一下纯css如何实现选框选中效果,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

选择器介绍:

1、“+”:如 div + p    选择紧接在 <div> 元素之后的所有 <p> 元素。

2、:checked :如 input:checked 单选框和复选框的选中状态。

实现代码:

<style type="text/css">
            .che-box {
            display:inline;
        }
        .che-box input{
            display: none;
        }
        .che-box label{
            display: inline-block;
            border: 1px solid #e1e1e1;
            border-radius: 4px;
            padding: 3px 5px;
        }
        .che-box input:checked + label{
            border-color: #088de8;
            background: #088de8;
            color: #fff;
        }
    </style>
 
 
<div class="che-box">
        <input type="checkbox" id="che1" />
        <label for="che1">
            标签1
        </label>
    </div>
    <div class="che-box">
        <input type="checkbox" id="che2" />
        <label for="che2">
            标签2
        </label>
    </div>

实现效果:

纯css如何实现选框选中效果

这情况主要用于 type=“checkbox,radio”的input 自定义选中样式的。

看完了这篇文章,相信你对纯css如何实现选框选中效果有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI