# 如何将 avatar\_template 移动到主题正文内

**URL:** <https://meta.discourse.org/t/how-to-move-the-avatar-template-inside-the-topic-body/344096>\
**Category:** Development\
**Tags:** css\
**Created:** [2024 年12 月 23 日 19:10 UTC](https://meta.discourse.org/t/how-to-move-the-avatar-template-inside-the-topic-body/344096 "2024-12-23T19:10:34Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

作者： ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)\
发布日期： [2024 年12 月 26 日 09:06 UTC](https://meta.discourse.org/t/how-to-move-the-avatar-template-inside-the-topic-body/344096/4 "2024-12-26T09:06:09Z")

</div>

你好 👋  
这是一个我刚做的例子，可能不完美，但你可以自定义……

桌面 / CSS

```scss
.topic-post {
  margin-bottom: 1em;
  > article > .row {
    background-color: var(--secondary);
    box-shadow: 0 0 0 1px var(--primary-low);
    border-radius: 1em;
    padding: 1em;

    .topic-avatar {
      border: none;
    }
    .topic-body {
      background: none;
      border: none;
      box-sizing: border-box;
      width: 100%;
      padding: 1em;
    }
  }

  .post-menu-area {
    margin: 1em 0 0;
  }
}

// 私信
.archetype-private_message {
  .regular.contents {
    border: none;
  }

  .topic-map {
    padding-left: 1em;
    padding-bottom: 0.25em;
  }

  .topic-post {
    margin-bottom: 1em;
  }

  // 使用当前用户帖子高亮显示整行
  .topic-post {
    &.current-user-post {
      > article > .row {
        background: var(--tertiary-very-low);
        box-shadow: 0 0 0 1px var(--tertiary-very-low);
      }
    }
    .regular.contents {
      background: none;
      border-color: none;
    }
  }
}

// 时间线
.topic-navigation.with-timeline {
  width: 150px;
}
.container.posts {
  // 确保帖子保持全宽度
  grid-template-columns: 1fr auto;

  .topic-navigation {
    margin-right: -2em;
    padding-left: 2em;
  }
}

// 主题图
.topic-map {
  &.--op,
  &.--bottom {
    padding: 1em 1em 0;
    max-width: 100%;
    border-top: none;
    border-bottom: none;
  }
}

// 小动作
.small-action {
  .topic-avatar,
  .small-action-desc {
    border-top: none;
    padding-top: 0;
  }
  .topic-avatar:empty {
    display: none;
  }
  .small-action-desc {
    width: calc(100% - 1em);
  }
}

// 帖子底部
.topic-area {
  > .loading-container {
    width: 100%;
  }
}
.topic-status-info,
.topic-timer-info {
  max-width: 100%;
}

```

---

_[View the full topic](https://meta.discourse.org/t/how-to-move-the-avatar-template-inside-the-topic-body/344096)._
