关闭边栏(ESC)打开边栏(ESC)
这种复选框或单选框挺好看的,亮点在勾选时,右下角有个打勾,这个是用一个边框作出来的效果,挺赞的
html
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 |
<h1 style="text-align: center;">纯CSS美化单选/复选框</h1> <ul class="ul_box"> <li> <div>单选框:</div> <div class="label_box"> <label> <input name="sex" type="radio"> <div>男</div> </label> <label> <input name="sex" type="radio"> <div>女</div> </label> </div> </li> <li> <div>复选框:</div> <div class="label_box"> <label> <input name="hobby" type="checkbox"> <div>旅游</div> </label> <label> <input name="hobby" type="checkbox"> <div>爬山</div> </label> <label> <input name="hobby" type="checkbox"> <div>游泳</div> </label> </div> </li> </ul> |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
.ul_box { margin:0 auto; padding:0; list-style:none; width:600px; } .ul_box>li { padding:10px 10px 0 10px; overflow:hidden; border-bottom:#e5e5e5 solid 1px; } .ul_box>li:last-child { border-bottom:none; } .ul_box>li>div { float:left; } .ul_box>li>div:nth-child(1) { width:100px; } .ul_box>li>div:nth-child(2) { width:480px; overflow:hidden; } .label_box>label { display:block; float:left; margin:0 10px 10px 0; position:relative; overflow:hidden; } .label_box>label>input { position:absolute; top:0; left:-20px; } .label_box>label>div { width:100px; text-align:center; border:#dddddd solid 1px; height:40px; line-height:40px; color:#666666; user-select:none; overflow:hidden; position:relative; } .label_box>label>input:checked + div { border:#d51917 solid 1px; color:#d51917; } .label_box>label>input:checked + div:after { content:''; display:block; width:20px; height:20px; background-color:#d51917; transform:skewY(-45deg); position:absolute; bottom:-10px; right:0; z-index:1; } .label_box>label>input:checked + div:before { content:''; display:block; width:3px; height:8px; border-right:#ffffff solid 2px; border-bottom:#ffffff solid 2px; transform:rotate(35deg); position:absolute; bottom:2px; right:4px; z-index:2; } |
我稍稍改了一下把它变成了二级联动的单选项,有空来瞧瞧
哇 很好哦 我来学习下联动的
很高级!~