在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
先看我们的第一个特效图 实例代码 复制代码 代码如下:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>CheckBox</title> <style> .checkbox { width: 900px; padding: 3% 0%; margin: 50px auto; background-color: cornsilk; text-align: center; }</p> <p> .checkbox label { display: inline-block; width: 64px; height: 32px; margin-right: 10px; background-color: #ffffff; border: 1px solid #eeeeee; border-radius: 17px; cursor: pointer; position: relative; transition: background-color .2s ease-in; }</p> <p> .checkbox label:after { content: ""; width: 30px; height: 30px; border-radius: 50%; background-color: #eeeeee; position: absolute; left: 1px; top: 1px; transform: translateX(0px); transition: transform .2s ease-in; }</p> <p> .checkbox [type="checkbox"]:checked + label { background-color: khaki; transition: background-color .2s ease-in; }</p> <p> .checkbox [type="checkbox"]:checked +label:after{ transform: translateX(30px); transition: transform .2s ease-in; }</p> <p> .checkbox [type="checkbox"]{ display: none; } </style> </head> <body> <div class="checkbox"> <input type="checkbox" id="checkbox-1"> <label for="checkbox-1"></label></p> <p> <input type="checkbox" id="checkbox-2"> <label for="checkbox-2"></label></p> <p> <input type="checkbox" id="checkbox-3"> <label for="checkbox-3"></label> </div></p> <p></body> </html> 再来看我们的第二个特效图 实例代码 复制代码 代码如下:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> .checkbox { width: 900px; padding: 3% 0px; margin: 50px auto; background-color: cornsilk; text-align: center; }</p> <p> .checkbox label { position: relative; display: inline-block; width: 30px; height: 30px; margin-right: 10px; overflow: hidden; border: 1px solid #eeeeee; background-color: #ffffff; cursor: pointer; }</p> <p> .checkbox label:after { content: "√"; position: absolute; width: 28px; height: 28px; line-height: 26px; background-color: khaki; color: #ffffff; left: 1px; top: 1px; text-align: center; transform: translateY(-30px); transition: transform .2s ease-out; border-radius: 4px; }</p> <p> .checkbox [type="checkbox"]:checked + label:after { transform: translateY(0px); transition: transform .2s ease-in; } .checkbox [type="checkbox"]{ display: none; } </style> </head> <body> <div class="checkbox"> <input type="checkbox" id="checkbox-1" checked="checked"> <label for="checkbox-1"></label></p> <p> <input type="checkbox" id="checkbox-2"> <label for="checkbox-2"></label></p> <p> <input type="checkbox" id="checkbox-3"> <label for="checkbox-3"></label> </div></p> <p></body> </html> 总结 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论