xChar
·2 days ago

友情链接 🥰

<div class="friend-links-row">
  <div class="friend-item">
    <img src="图片地址A" alt="博客A" />
    <div>
      <strong>
        <a href="https://www.xxx.com/" target="_blank" rel="noopener noreferrer">@博客名称</a>
      </strong>
      <div>博客简介OZR</div>
    </div>
  </div>
  <div class="friend-item">
    <img src="图片地址B" alt="博客A" />
    <div>
      <strong>
        <a href="https://www.xxx.com/" target="_blank" rel="noopener noreferrer">@博客名称</a>
      </strong>
      <div>博客简介OZR</div>
    </div>
  </div>
  <div class="friend-item">
    <img src="图片地址C" alt="博客C" />
    <div>
      <strong>
        <a href="https://www.xxx.com/" target="_blank" rel="noopener noreferrer">@博客名称</a>
      </strong>
      <div>博客简介OZR</div>
    </div>
  </div>
</div>

<!-- 另外起一行可以直接复制这整个代码块 -->


另外加入CSS:

.friend-links-row {
  display: flex;
  flex-wrap: wrap;              /* 允许换行 */
  justify-content: center;      /* 居中显示 */
  gap: 24px 16px;               /* 行间距、列间距 */
  margin-bottom: 30px;
}

.friend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 220px;                 /* 默认宽度,适合大部分屏幕 */
  background: #fff;
  border-radius: 16px;
  padding: 20px 12px 16px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: box-shadow 0.2s;
  margin-bottom: 0;
}

.friend-item:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}

.friend-item img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #eee;
  margin-bottom: 12px;
  display: block;
}

.friend-item strong {
  font-size: 1.08em;
  color: #222;
  margin-bottom: 6px;
  text-align: center;
  word-break: break-all;
}

.friend-item strong {
  font-size: 1.08em;
  color: #222;
  margin-bottom: 6px;
  text-align: center;
  word-break: break-all;
  display: block;           /* 关键:让 strong 占满一行 */
  width: 100%;              /* 关键:宽度100% */
}

.friend-item strong a {
  color: #222;
  text-decoration: none;
  transition: color 0.2s;
  display: block;           /* 关键:让 a 也占满一行 */
  text-align: center;       /* 关键:居中 */
  width: 100%;
}

.friend-item div > div {
  color: #888;
  font-size: 1em;
  margin-top: 2px;
  text-align: center;
  word-break: break-all;
}

/* 响应式:手机端优化 */
@media (max-width: 600px) {
  .friend-links-row {
    gap: 16px 0;
  }
  .friend-item {
    width: 90vw;                
    max-width: 340px;
    min-width: 0;
    margin: 0 auto;
    padding: 16px 6px 12px 6px;
  }
  .friend-item img {
    width: 60px;
    height: 60px;
  }
}

代码由Cursor生成,亲测有效。如有问题欢迎在下面留言~

Loading comments...