CSS100Day(27)-清单列表使用input替换JS

784 字
4 分钟
CSS100Day(27)-清单列表使用input替换JS

设计简介#

关键点如下

  1. 知识点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代码

分享给其他人
如果该文章对您有帮助,欢迎分享给其他人阅读!
复制链接

评论区

图片
犟哟
Hello, I'm Juyial.
公告
欢迎来到我的博客,在这里可以一起进步,一起学习!2026年起航!
分类
站点统计
文章
26
分类
1
标签
3
总字数
47,878
运行时长
0
最后活动
0 天前

目录