|
3 | 3 | icon: fas fa-link |
4 | 4 | order: 4 |
5 | 5 | --- |
6 | | - |
7 | 6 | <div class="friend-links-container"> |
8 | 7 | {% 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"> |
10 | 9 | <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;" /> |
12 | 11 | </div> |
13 | 12 | <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> |
16 | 15 | </div> |
17 | 16 | </a> |
18 | 17 | {% endfor %} |
19 | 18 | </div> |
20 | 19 |
|
21 | 20 | <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 | + /* 友链网格布局容器 */ |
22 | 29 | .friend-links-container { |
23 | 30 | display: grid; |
24 | 31 | grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); |
25 | | - gap: 20px; /* 卡片之间的间距 */ |
| 32 | + gap: 1rem; /* 卡片间距 */ |
26 | 33 | } |
27 | 34 |
|
| 35 | + /* 核心:卡片本身 (<a> 标签) */ |
28 | 36 | .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; |
38 | 47 | } |
39 | 48 |
|
| 49 | + /* 鼠标悬浮效果 */ |
40 | 50 | .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; |
44 | 54 | } |
45 | 55 |
|
| 56 | + /* 卡片头像容器 */ |
46 | 57 | .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; /* 头像和文字之间的距离 */ |
51 | 62 | } |
52 | 63 |
|
| 64 | + /* 头像图片 */ |
53 | 65 | .friend-card-avatar img { |
54 | 66 | width: 100%; |
55 | 67 | height: 100%; |
56 | 68 | border-radius: 50%; /* 圆形头像 */ |
57 | | - object-fit: cover; |
58 | | - background-color: #fff; /* 防止透明背景的png图片看起来奇怪 */ |
| 69 | + object-fit: cover; /* 保证图片不变形 */ |
| 70 | + border: 1px solid #f0f0f0; /* 给头像加个细边框 */ |
59 | 71 | } |
60 | 72 |
|
| 73 | + /* 卡片信息区域 */ |
61 | 74 | .friend-card-info { |
62 | | - overflow: hidden; /* 防止文字过长溢出 */ |
| 75 | + overflow: hidden; /* 防止文字溢出 */ |
| 76 | + display: flex; |
| 77 | + flex-direction: column; |
| 78 | + justify-content: center; |
63 | 79 | } |
64 | 80 |
|
| 81 | + /* 网站名称 */ |
65 | 82 | .friend-card-name { |
66 | 83 | font-size: 1.1em; |
67 | 84 | font-weight: bold; |
68 | | - color: #333; |
| 85 | + margin: 0; |
| 86 | + padding: 0; |
69 | 87 | white-space: nowrap; |
70 | 88 | overflow: hidden; |
71 | | - text-overflow: ellipsis; /* 名字太长时显示省略号 */ |
| 89 | + text-overflow: ellipsis; |
72 | 90 | } |
73 | 91 |
|
| 92 | + /* 网站描述 */ |
74 | 93 | .friend-card-desc { |
75 | 94 | font-size: 0.9em; |
76 | | - color: #6c757d; |
77 | | - margin-top: 5px; |
| 95 | + color: #888; |
| 96 | + margin: 5px 0 0 0; /* 与标题的上边距 */ |
| 97 | + padding: 0; |
78 | 98 | white-space: nowrap; |
79 | 99 | overflow: hidden; |
80 | | - text-overflow: ellipsis; /* 简介太长时显示省略号 */ |
| 100 | + text-overflow: ellipsis; |
81 | 101 | } |
82 | 102 | </style> |
0 commit comments