Skip to content

Commit f2a9125

Browse files
update friends style
1 parent 6bd76ad commit f2a9125

File tree

1 file changed

+50
-30
lines changed

1 file changed

+50
-30
lines changed

_tabs/friends.md

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,80 +3,100 @@
33
icon: fas fa-link
44
order: 4
55
---
6-
76
<div class="friend-links-container">
87
{% for friend in site.data.friends %}
9-
<a href="{{ friend.url }}" target="_blank" class="friend-card" title="{{ friend.name }}">
8+
<a href="{{ friend.url }}" target="_blank" rel="noopener" class="friend-card">
109
<div class="friend-card-avatar">
11-
<img src="{{ friend.avatar }}" alt="{{ friend.name }}'s avatar" onerror="this.src='https://www.google.com/s2/favicons?domain={{ friend.url | split: '//' | last | split: '/' | first }}'; this.onerror=null;" />
10+
<img src="{{ friend.avatar }}" alt="{{ friend.name }}'s avatar" loading="lazy" onerror="this.src='https://www.google.com/s2/favicons?domain={{ friend.url | split: '//' | last | split: '/' | first }}'; this.onerror=null;" />
1211
</div>
1312
<div class="friend-card-info">
14-
<div class="friend-card-name">{{ friend.name }}</div>
15-
<div class="friend-card-desc">{{ friend.desc }}</div>
13+
<strong class="friend-card-name">{{ friend.name }}</strong>
14+
<p class="friend-card-desc">{{ friend.desc }}</p>
1615
</div>
1716
</a>
1817
{% endfor %}
1918
</div>
2019

2120
<style>
21+
/* 确保所有元素盒模型统一,避免 padding 导致尺寸混乱 */
22+
.friend-links-container *,
23+
.friend-links-container *::before,
24+
.friend-links-container *::after {
25+
box-sizing: border-box;
26+
}
27+
28+
/* 友链网格布局容器 */
2229
.friend-links-container {
2330
display: grid;
2431
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
25-
gap: 20px; /* 卡片之间的间距 */
32+
gap: 1rem; /* 卡片间距 */
2633
}
2734

35+
/* 核心:卡片本身 (<a> 标签) */
2836
.friend-card {
29-
display: flex;
30-
align-items: center;
31-
padding: 15px;
32-
border-radius: 8px;
33-
background-color: #f8f9fa; /* 卡片背景色,你可以根据你的主题调整 */
34-
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
35-
transition: all 0.3s ease;
36-
color: inherit; /* 继承父元素的文字颜色 */
37-
text-decoration: none; /* 去掉下划线 */
37+
display: flex; /* <-- 这是让头像和信息并排的关键!*/
38+
align-items: center; /* 垂直居中对齐 */
39+
text-decoration: none !important; /* !important 用来强制去掉下划线 */
40+
color: #333; /* 默认文字颜色 */
41+
background-color: #fff; /* 卡片背景色 */
42+
padding: 1rem;
43+
border-radius: 12px;
44+
border: 1px solid #eee; /* 添加一个细边框,看起来更精致 */
45+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
46+
transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
3847
}
3948

49+
/* 鼠标悬浮效果 */
4050
.friend-card:hover {
41-
transform: translateY(-5px);
42-
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
43-
background-color: #ffffff; /* 鼠标悬浮时的背景色 */
51+
transform: translateY(-4px);
52+
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
53+
border-color: #ddd;
4454
}
4555

56+
/* 卡片头像容器 */
4657
.friend-card-avatar {
47-
flex-shrink: 0;
48-
width: 50px;
49-
height: 50px;
50-
margin-right: 15px;
58+
flex-shrink: 0; /* 防止头像被压缩 */
59+
width: 55px;
60+
height: 55px;
61+
margin-right: 1rem; /* 头像和文字之间的距离 */
5162
}
5263

64+
/* 头像图片 */
5365
.friend-card-avatar img {
5466
width: 100%;
5567
height: 100%;
5668
border-radius: 50%; /* 圆形头像 */
57-
object-fit: cover;
58-
background-color: #fff; /* 防止透明背景的png图片看起来奇怪 */
69+
object-fit: cover; /* 保证图片不变形 */
70+
border: 1px solid #f0f0f0; /* 给头像加个细边框 */
5971
}
6072

73+
/* 卡片信息区域 */
6174
.friend-card-info {
62-
overflow: hidden; /* 防止文字过长溢出 */
75+
overflow: hidden; /* 防止文字溢出 */
76+
display: flex;
77+
flex-direction: column;
78+
justify-content: center;
6379
}
6480

81+
/* 网站名称 */
6582
.friend-card-name {
6683
font-size: 1.1em;
6784
font-weight: bold;
68-
color: #333;
85+
margin: 0;
86+
padding: 0;
6987
white-space: nowrap;
7088
overflow: hidden;
71-
text-overflow: ellipsis; /* 名字太长时显示省略号 */
89+
text-overflow: ellipsis;
7290
}
7391

92+
/* 网站描述 */
7493
.friend-card-desc {
7594
font-size: 0.9em;
76-
color: #6c757d;
77-
margin-top: 5px;
95+
color: #888;
96+
margin: 5px 0 0 0; /* 与标题的上边距 */
97+
padding: 0;
7898
white-space: nowrap;
7999
overflow: hidden;
80-
text-overflow: ellipsis; /* 简介太长时显示省略号 */
100+
text-overflow: ellipsis;
81101
}
82102
</style>

0 commit comments

Comments
 (0)