AI 生成: 一个简洁的待办事项 Web 应用,支持添加、完成、删除任务,并使用 localStorage 在浏览器本地保存数据。

This commit is contained in:
admin
2026-09-28 20:05:39 +08:00
commit 3cf7cbe814
4 changed files with 434 additions and 0 deletions
+176
View File
@@ -0,0 +1,176 @@
:root {
--bg: #f5f7fb;
--card: #ffffff;
--text: #1f2937;
--muted: #6b7280;
--primary: #2563eb;
--primary-hover: #1d4ed8;
--danger: #ef4444;
--border: #e5e7eb;
--done: #9ca3af;
--shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-height: 100vh;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background: linear-gradient(180deg, #eef2ff 0%, var(--bg) 100%);
color: var(--text);
display: flex;
justify-content: center;
padding: 40px 16px;
}
.app {
width: 100%;
max-width: 560px;
background: var(--card);
border-radius: 16px;
box-shadow: var(--shadow);
padding: 28px;
}
.app-header h1 {
margin: 0;
font-size: 28px;
letter-spacing: -0.5px;
}
.subtitle {
margin: 6px 0 22px;
color: var(--muted);
font-size: 14px;
}
.todo-form {
display: flex;
gap: 10px;
}
.todo-input {
flex: 1;
padding: 12px 14px;
border: 1px solid var(--border);
border-radius: 10px;
font-size: 15px;
outline: none;
transition: border-color 0.2s, box-shadow 0.2s;
}
.todo-input:focus {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.add-btn {
padding: 12px 18px;
border: none;
border-radius: 10px;
background: var(--primary);
color: #fff;
font-size: 15px;
font-weight: 600;
cursor: pointer;
transition: background 0.2s;
}
.add-btn:hover {
background: var(--primary-hover);
}
.todo-stats {
display: flex;
justify-content: space-between;
align-items: center;
margin: 18px 0 10px;
color: var(--muted);
font-size: 13px;
}
.clear-btn {
background: transparent;
border: none;
color: var(--muted);
cursor: pointer;
font-size: 13px;
}
.clear-btn:hover {
color: var(--danger);
}
.todo-list {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 8px;
}
.todo-item {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 14px;
border: 1px solid var(--border);
border-radius: 10px;
background: #fff;
transition: background 0.2s, transform 0.1s;
}
.todo-item:hover {
background: #fafafa;
}
.todo-item input[type="checkbox"] {
width: 18px;
height: 18px;
accent-color: var(--primary);
cursor: pointer;
flex-shrink: 0;
}
.todo-text {
flex: 1;
font-size: 15px;
word-break: break-word;
}
.todo-item.completed .todo-text {
text-decoration: line-through;
color: var(--done);
}
.delete-btn {
border: none;
background: transparent;
color: var(--muted);
font-size: 18px;
line-height: 1;
cursor: pointer;
padding: 4px 8px;
border-radius: 6px;
transition: background 0.2s, color 0.2s;
}
.delete-btn:hover {
background: #fee2e2;
color: var(--danger);
}
.empty-state {
margin: 24px 0 0;
text-align: center;
color: var(--muted);
font-size: 14px;
}
.empty-state.hidden {
display: none;
}