feat: 完善 Grid 布局主页的所有卡片内容与样式

- **Profile**: 完成个人信息展示,适配桌面(居中)与移动端(左图右文)布局。
- **RSS**: 接入少数派文章数据(静态模拟),优化列表视觉效果及底部“查看更多”按钮。
- **Task**: 实现待办事项列表样式,优化间距与交互反馈,清理无用标签。
- **Hitokoto**: 集成一言 API(内联 JS),支持出处展示与跳转。
- **Photos**: 替换为本地图片资源,去除边框以提升沉浸感,并限制高度以防止布局变形。
- **Layout**: 全局添加 `box-sizing: border-box`,微调 Grid 行高、间距及边距,解决垂直滚动条问题。
- **Mobile**: 优化移动端响应式表现,确保内容在不同设备上的可读性。
This commit is contained in:
Coldin04 2026-01-23 14:57:23 +08:00
parent f35de394fc
commit 5b79d2179f
2 changed files with 385 additions and 16 deletions

View file

@ -21,12 +21,93 @@
</header> </header>
<div class="main-content"> <div class="main-content">
<main class="dashboard-grid"> <main class="dashboard-grid">
<section class="card card__profile">个人卡片区域</section> <section class="card card__profile">
<section class="card card__rss">RSS News区域</section> <div class="profile">
<section class="card card__task">任务区域</section> <img src="src/avatar_240.webp" alt="头像" class="profile__avatar">
<section class="card card__hitokoto">一言</section> <div class="profile__content">
<section class="card card__photos">Photos 区域</section> <h2 class="profile__name">Coldin04</h2>
<p class="profile__signature">Stay hungry, stay foolish.</p>
</div>
</div>
</section>
<section class="card card__rss">
<div class="rss-wrapper">
<div class="rss-header">
<h3>少数派 Prime</h3>
<span class="rss-status">sspai.com</span>
</div>
<div class="rss-list">
<article class="rss-item">
<div class="rss-meta">
<span class="rss-tag">SamWanng</span>
<time>Jan 23</time>
</div>
<h4><a href="https://sspai.com/post/105578" target="_blank">一日一技 | 老 Mac 系统恢复指北</a></h4>
<p>不能用 Wi-Fi 和 U 盘恢复系统的 Mac你还能试试这个重装方法。</p>
</article>
<article class="rss-item">
<div class="rss-meta">
<span class="rss-tag">少数派编辑部</span>
<time>Jan 23</time>
</div>
<h4><a href="https://sspai.com/post/105695" target="_blank">派早报realme 真我发布新品、Xbox 应用登陆 Arm PC 等</a></h4>
<p>索尼发布 LinkBuds Clip 开放式耳机、Adobe 将支持把 PDF 转换成播客等。</p>
</article>
</article>
</div>
<div class="rss-footer">
<a href="https://sspai.com" target="_blank" class="rss-more-btn">查看更多内容 →</a>
</div>
</div>
</section>
<section class="card card__task">
<div class="task-container">
<div class="task-header">
<h3>待办事项</h3>
<span class="task-count">4 items</span>
</div>
<ul class="task-list">
<li class="task-item">
<input type="checkbox" id="task1" checked>
<label for="task1" class="task-content">完成 Grid 布局学习</label>
</li>
<li class="task-item">
<input type="checkbox" id="task2">
<label for="task2" class="task-content">完善个人主页样式</label>
</li>
<li class="task-item">
<input type="checkbox" id="task3">
<label for="task3" class="task-content">其实这些只是测试文本</label>
</li>
<li class="task-item">
<input type="checkbox" id="task4">
<label for="task4" class="task-content">优化移动端体验</label>
</li>
</ul>
</div>
</section>
<section class="card card__hitokoto">
<div class="hitokoto-content">
<a href="#" id="hitokoto_text" class="hitokoto__text" target="_blank" style="text-decoration: none; color: inherit; display: block;">:D 获取中...</a>
<p id="hitokoto_from" class="hitokoto__from"></p>
</div>
</section>
<section class="card card__photos" style="border: none;">
<img src="src/wallpaper/desert.webp" alt="Photo" loading="lazy">
</section>
</main> </main>
</div> </div>
<script>
fetch('https://v1.hitokoto.cn')
.then(response => response.json())
.then(data => {
const hitokoto = document.querySelector('#hitokoto_text')
const from = document.querySelector('#hitokoto_from')
hitokoto.href = `https://hitokoto.cn/?uuid=${data.uuid}`
hitokoto.innerText = data.hitokoto
if (from) from.innerText = `—— ${data.from}`
})
.catch(console.error)
</script>
</body> </body>
</html> </html>

View file

@ -1,15 +1,15 @@
html, body { height: 100%; } * {
box-sizing: border-box;
}
body { body {
/* 使用 Bing 图片作为背景 */
background-image: url('src/wallpaper/big_sure.webp'); background-image: url('src/wallpaper/big_sure.webp');
background-size: cover; background-size: cover;
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
background-attachment: fixed; background-attachment: fixed;
/* 保持高度设置 */
min-height: 100vh;
margin: 0;
} }
/* 顶栏样式 */ /* 顶栏样式 */
@ -80,13 +80,13 @@ body {
.main-content { .main-content {
gap: 24px; gap: 24px;
max-width: 1200px; /* 最大宽度限制 */ max-width: 1200px; /* 最大宽度限制 */
margin: 40px auto; margin: 20px auto;
padding: 0 20px 40px 20px; padding: 0 80px 20px 80px;
} }
.dashboard-grid{ .dashboard-grid{
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
grid-auto-rows: minmax(200px, auto); /* 自动行高 */ grid-auto-rows: minmax(150px, auto); /* 自动行高 */
grid-auto-flow: dense; /* 紧凑排列 */ grid-auto-flow: dense; /* 紧凑排列 */
gap: 24px; gap: 24px;
} }
@ -101,7 +101,6 @@ body {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 16px; gap: 16px;
margin-bottom: 16px;
transition: var(--transition); transition: var(--transition);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
} }
@ -115,28 +114,301 @@ body {
.card__profile{ .card__profile{
grid-column: span 1; grid-column: span 1;
grid-row: span 2; grid-row: span 2;
flex-direction: column;
justify-content: center;
align-items: center;
}
/* 个人卡片样式 */
.profile {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
gap: 16px;
width: 100%;
}
.profile__avatar {
width: 120px;
height: 120px;
border-radius: 50%;
object-fit: cover;
border: 4px solid rgba(255, 255, 255, 0.8);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.profile__avatar:hover {
transform: scale(1.05);
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}
.profile__content {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
}
.profile__name {
margin: 0;
font-size: 24px;
font-weight: 600;
color: #333;
letter-spacing: 0.5px;
}
.profile__signature {
margin: 0;
font-size: 14px;
color: #666;
font-style: italic;
max-width: 200px;
line-height: 1.5;
} }
.card__rss{ .card__rss{
grid-column: span 2; grid-column: span 2;
grid-row: span 2; grid-row: span 2;
align-items: flex-start;
}
/* RSS 区域样式 */
.rss-wrapper {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.rss-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid rgba(0,0,0,0.06);
}
.rss-header h3 {
margin: 0;
font-size: 18px;
font-weight: 600;
color: #1d1d1f;
}
.rss-status {
font-size: 12px;
color: #86868b;
background: rgba(0,0,0,0.05);
padding: 4px 10px;
border-radius: 12px;
}
.rss-list {
flex: 1;
display: flex;
flex-direction: column;
gap: 16px;
overflow-y: auto;
padding-right: 4px;
}
.rss-item {
display: flex;
flex-direction: column;
gap: 4px;
}
.rss-meta {
display: flex;
align-items: center;
gap: 8px;
font-size: 12px;
color: #86868b;
}
.rss-tag {
color: #d93535;
font-weight: 500;
}
.rss-item h4 {
margin: 0;
font-size: 15px;
font-weight: 600;
line-height: 1.4;
}
.rss-item h4 a {
color: #1d1d1f;
text-decoration: none;
transition: color 0.2s;
}
.rss-item h4 a:hover {
color: #d93535;
}
.rss-item p {
margin: 4px 0 0 0;
font-size: 13px;
color: #666;
line-height: 1.5;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.rss-footer {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid rgba(0,0,0,0.06);
text-align: center;
}
.rss-more-btn {
display: inline-block;
padding: 6px 16px;
font-size: 13px;
color: #d93535;
background-color: rgba(217, 53, 53, 0.1);
border-radius: 16px;
text-decoration: none;
font-weight: 500;
transition: all 0.2s;
}
.rss-more-btn:hover {
background-color: #d93535;
color: white;
} }
.card__hitokoto{ .card__hitokoto{
grid-column: span 1; grid-column: span 1;
grid-row: span 1; grid-row: span 1;
justify-content: center;
} }
.card__photo{ /* 一言样式 */
.hitokoto-content {
width: 100%;
}
.hitokoto__text {
font-size: 18px;
line-height: 1.6;
margin: 0 0 8px 0;
text-align: center;
font-weight: 500;
}
.hitokoto__from {
font-size: 13px;
color: #888;
text-align: right;
margin: 0;
}
.card__photos{
grid-column: span 1; grid-column: span 1;
grid-row: span 1; grid-row: span 1;
padding: 0;
overflow: hidden;
height: 180px;
}
.card__photos img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
} }
.card__task{ .card__task{
grid-column: span 2; grid-column: span 2;
grid-row: span 2; grid-row: span 2;
align-items: flex-start;
} }
/* 任务列表样式 */
.task-container {
width: 100%;
display: flex;
flex-direction: column;
}
.task-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid rgba(0,0,0,0.06);
}
.task-header h3 {
margin: 0;
font-size: 18px;
font-weight: 600;
color: #1d1d1f;
}
.task-count {
font-size: 12px;
color: #86868b;
background: rgba(0,0,0,0.05);
padding: 4px 10px;
border-radius: 12px;
}
.task-list {
list-style: none;
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
gap: 2px;
}
.task-item {
display: flex;
align-items: center;
gap: 12px;
padding: 6px 8px;
border-radius: 8px;
transition: background-color 0.2s ease;
}
.task-item:hover {
background-color: rgba(0,0,0,0.03);
}
.task-item input[type="checkbox"] {
width: 18px;
height: 18px;
margin: 0;
accent-color: #0071e3;
cursor: pointer;
}
.task-content {
flex: 1;
font-size: 15px;
color: #333;
cursor: pointer;
transition: all 0.2s ease;
}
/* 完成状态 */
.task-item input:checked + .task-content {
text-decoration: line-through;
color: #86868b;
}
/* 响应式设计 */ /* 响应式设计 */
@media (max-width: 900px) { @media (max-width: 900px) {
.dashboard-grid { .dashboard-grid {
@ -144,9 +416,13 @@ body {
} }
} }
@media (max-width: 600px) { @media (max-width: 600px) {
.main-content {
padding: 0 20px 40px 20px;
}
.dashboard-grid { .dashboard-grid {
grid-template-columns: 1fr; grid-template-columns: 1fr;
gap: 16px; gap: 16px;
grid-auto-rows: auto;
} }
.card { .card {
grid-column: span 1 !important; grid-column: span 1 !important;
@ -157,10 +433,22 @@ body {
grid-column: span 1; grid-column: span 1;
order: 1; order: 1;
} }
.profile {
flex-direction: row;
text-align: left;
align-items: center;
}
.profile__avatar {
width: 80px;
height: 80px;
}
.card__rss,.card__task{ .card__rss,.card__task{
grid-column: span 1; grid-column: span 1;
} }
.card__hitokoto{ .card__hitokoto{
order: 2; order: 2;
} }
.card__photos {
height: 140px;
}
} }