CSS100Day(27)-清单列表使用input替换JS
784 字
4 分钟
CSS100Day(27)-清单列表使用input替换JS
设计简介
关键点如下
- 知识点1:利用input
效果展示
星期五
2026年6月19日
实现代码和步骤
HTML部分
<div class="frame"> <div class="list"> <div class="head"> <div class="title">星期五</div> <div class="subTitle">2026年6月19日</div> </div> <ul> <li> <input type="checkbox" id="item-1" name="item-1" /> <label for="item-1" class="text">添加任务清单列表</label> <label for="item-1" class="button"></label> <svg width="15px" height="10px" class="checkmark"> <polyline points="1,5 6,9 14,1" /> </svg> </li> <li> <input type="checkbox" id="item-2" name="item-2" /> <label for="item-2" class="text">完成第一项任务</label> <label for="item-2" class="button"></label> <svg width="15px" height="10px" class="checkmark"> <polyline points="1,5 6,9 14,1" /> </svg> </li> <li> <input type="checkbox" id="item-3" name="item-3" /> <label for="item-3" class="text">编写css内容</label> <label for="item-3" class="button"></label> <svg width="15px" height="10px" class="checkmark"> <polyline points="1,5 6,9 14,1" /> </svg> </li> <li> <input type="checkbox" id="item-4" name="item-4" /> <label for="item-4" class="text">震惊整个世界</label> <label for="item-4" class="button"></label> <svg width="15px" height="10px" class="checkmark"> <polyline points="1,5 6,9 14,1" /> </svg> </li> </ul> </div></div>CSS部分
.frame { width: 400px; height: 400px; border-radius: 2px; box-shadow: 1px 2px 10px 0 rgba(0, 0, 0, 0.3); color: #497081; background: linear-gradient(to top right, #fda231 0%, #fdca31 100%); display: flex; align-items: center; justify-content: center;}
.list { width: 240px; height: 280px; background: #fff; border-radius: 3px; box-shadow: 4px 8px 12px 0 rgba(0, 0, 0, 0.2); display: flex; flex-direction: column; .head { text-align: center; padding: 20px 0; margin: 0 30px; border-bottom: 1px solid #d4dce0; } .title { font-weight: 600; font-size: 20px; line-height: 30px; text-align: center; } .subTitle { font-size: 12px; line-height: 18px; text-align: center; } ul { list-style: none; padding: 4px 0; margin: 0 30px; position: relative; li { position: relative; display: block; margin: 24px 0; height: 14px; display: flex; justify-content: space-between; align-items: center; } .text { font-size: 13px; line-height: 14px; cursor: pointer; transition: all 0.3s ease-in-out; } .button { position: relative; z-index: 2; box-sizing: border-box; float: right; width: 14px; height: 14px; border: 1px solid #497081; border-radius: 50%; cursor: pointer; transition: all 0.4s ease-out 0.5s; } .checkmark { position: absolute; top: 2px; right: 0; stroke: #c8d4d9; fill: none; stroke-width: 1.5; stroke-dasharray: 30 30; stroke-dashoffset: 30; transition: all 0.5s ease-out; } input { display: none; &:checked ~ .text { color: #c8d4d9; } &:checked ~ .button { transition: all 0.4s ease-in; scale: 1.5; opacity: 0; } &:checked ~ .checkmark { stroke-dashoffset: 0; transition: all 0.5s ease-out 0.4s; } } }}JS部分
无JS代码
分享给其他人
如果该文章对您有帮助,欢迎分享给其他人阅读!
复制链接
相关文章
推荐筛选
1
CSS100Day(22)-使用svg实现圆形进度条
设计灵感 使用svg实现圆形进度条
2
CSS100Day(20)-发送邮件惊艳动画无JS
设计灵感 纯css实现发送邮件,利用checkbox
3
CSS100Day(7)-菜单列表和公告在一起
设计灵感 菜单隐藏在后面,利用transform的translateX点击移动展开
4
CSS100Day(28)-振铃动画
设计灵感 振铃动画
5
CSS100Day(26)-激励卡片切换
设计灵感 激励卡片切换
随机文章
随机推荐