|
3 | 3 | icon: fas fa-link |
4 | 4 | order: 4 |
5 | 5 | --- |
| 6 | + |
| 7 | +<div class="friend-links-container"> |
| 8 | + {% for friend in site.data.friends %} |
| 9 | + <a href="{{ friend.url }}" target="_blank" class="friend-card" title="{{ friend.name }}"> |
| 10 | + <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;" /> |
| 12 | + </div> |
| 13 | + <div class="friend-card-info"> |
| 14 | + <div class="friend-card-name">{{ friend.name }}</div> |
| 15 | + <div class="friend-card-desc">{{ friend.desc }}</div> |
| 16 | + </div> |
| 17 | + </a> |
| 18 | + {% endfor %} |
| 19 | +</div> |
| 20 | + |
| 21 | +<style> |
| 22 | + .friend-links-container { |
| 23 | + display: grid; |
| 24 | + grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); |
| 25 | + gap: 20px; /* 卡片之间的间距 */ |
| 26 | + } |
| 27 | + |
| 28 | + .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; /* 去掉下划线 */ |
| 38 | + } |
| 39 | + |
| 40 | + .friend-card:hover { |
| 41 | + transform: translateY(-5px); |
| 42 | + box-shadow: 0 4px 12px rgba(0,0,0,0.1); |
| 43 | + background-color: #ffffff; /* 鼠标悬浮时的背景色 */ |
| 44 | + } |
| 45 | + |
| 46 | + .friend-card-avatar { |
| 47 | + flex-shrink: 0; |
| 48 | + width: 50px; |
| 49 | + height: 50px; |
| 50 | + margin-right: 15px; |
| 51 | + } |
| 52 | + |
| 53 | + .friend-card-avatar img { |
| 54 | + width: 100%; |
| 55 | + height: 100%; |
| 56 | + border-radius: 50%; /* 圆形头像 */ |
| 57 | + object-fit: cover; |
| 58 | + background-color: #fff; /* 防止透明背景的png图片看起来奇怪 */ |
| 59 | + } |
| 60 | + |
| 61 | + .friend-card-info { |
| 62 | + overflow: hidden; /* 防止文字过长溢出 */ |
| 63 | + } |
| 64 | + |
| 65 | + .friend-card-name { |
| 66 | + font-size: 1.1em; |
| 67 | + font-weight: bold; |
| 68 | + color: #333; |
| 69 | + white-space: nowrap; |
| 70 | + overflow: hidden; |
| 71 | + text-overflow: ellipsis; /* 名字太长时显示省略号 */ |
| 72 | + } |
| 73 | + |
| 74 | + .friend-card-desc { |
| 75 | + font-size: 0.9em; |
| 76 | + color: #6c757d; |
| 77 | + margin-top: 5px; |
| 78 | + white-space: nowrap; |
| 79 | + overflow: hidden; |
| 80 | + text-overflow: ellipsis; /* 简介太长时显示省略号 */ |
| 81 | + } |
| 82 | +</style> |
0 commit comments