本文摘自PHP中文网,作者V,侵删。

选择器介绍:
1、“+”:如 div + p 选择紧接在 <div> 元素之后的所有 <p> 元素。
2、:checked :如 input:checked 单选框和复选框的选中状态。
(学习视频分享:css视频教程)
实现代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | < 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中device-width与width有什么区别
css怎么改变鼠标形状
css里面的rgba有几个值
css怎么取消边框
css flex布局的优缺点是什么
css怎么设置字体间隔
css text-shadow属性怎么用
css中submit意思是什么
分享div+css前端命名的规则
css如何将图片设置为圆形图片
更多相关阅读请进入《css》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » 纯css实现选框选中效果