# 房源广告模板

**URL:** <https://meta.discourse.org/t/house-ad-templates/122004>\
**Category:** Site Management\
**Tags:** advertising, how-to\
**Created:** [2019年七月3日 12:29 UTC](https://meta.discourse.org/t/house-ad-templates/122004 "2019-07-03T12:29:11Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![becl](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@becl](https://meta.discourse.org/u/becl)\
**Post date:** [2025年四月14日 00:55 UTC](https://meta.discourse.org/t/house-ad-templates/122004/81 "2025-04-14T00:55:55Z")

</div>

> [@Discourse](#):
>
> ```plaintext
> <a href="DESTINATION_URL" class="banner-ad" target="_blank">
> <img class="desktop" src="DESKTOP_IMAGE_URL">
> <img class="mobile" src="MOBILE_IMAGE_URL">
> <div class="container">
> <div>
> <p class="big">一个响应式横幅广告</p>
> <p class="small">自定义以符合您的喜好。</p>
> </div>
> <button class="btn btn-default cta">
> <span class="d-button-label">点击这里！</span>
> </button>
> </div>
> </a>
> 
> ```

你好 Clay，我正在回复你以前的一篇帖子。我也想在不同的类别中展示不同的插播广告。你最后能实现这个功能吗？我向下滚动了这篇帖子，但没有看到对你问题的回复。

祝好

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2025年四月14日 01:02 UTC](https://meta.discourse.org/t/house-ad-templates/122004/82 "2025-04-14T01:02:14Z")

</div>

我认为我已经完成了，方法是制作一堆广告，然后用 CSS 按类别隐藏它们。

---

<div class="post-metadata">

**Author:** ![becl](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@becl](https://meta.discourse.org/u/becl)\
**Post date:** [2025年四月14日 05:47 UTC](https://meta.discourse.org/t/house-ad-templates/122004/83 "2025-04-14T05:47:14Z")

</div>

您好 pfaffman，

在拜读了您的帖子后，我向 Google Gemini 询问了可在 CSS 和 HTML 中使用的代码。

但是，它现在根本不显示广告了。

这是它建议使用的 CSS，但不确定是否正确。

```plaintext
/* -------------------------------------------------------------------------- */
/* CSS to control which ads are displayed in which categories */
/* -------------------------------------------------------------------------- */

/* Initially hide all category-specific ads. The [class*=\"-ad\"] selector is more general */
.house-ad[class*=\"-ad\"] {
  display: none;
}

/* Homepage Ad (if you have one - adjust the body class if needed) */
body.list-latest .house-ad.homepage-ad,
body.list-top .house-ad.homepage-ad {
  /* body.list-latest and body.list-top are common Discourse classes for \"Latest\" and \"Top\" */
  display: block;
}

/* Category Specific Ads */
body.category-community-support .house-ad.category-community-support-ad {
  display: block;
}
body.category-general .house-ad.category-general-ad {
  display: block;
}

```

您是否有可能告诉我您使用的 CSS，或者我发布的 CSS 是否看起来正确？

这是 HTML

```html
<div class="house-ad category-community-support-ad">
  <a href="DESTINATION_URL" class="banner-ad" target="_blank">
    <img class="desktop" src="DESKTOP_IMAGE_URL">
    <img class="mobile" src="MOBILE_IMAGE_URL">
  </a>
</div>

```

---

<div class="post-metadata">

**Author:** ![clayg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clayg/32/181131_2.png) [@clayg](https://meta.discourse.org/u/clayg)\
**Post date:** [2025年四月14日 18:35 UTC](https://meta.discourse.org/t/house-ad-templates/122004/84 "2025-04-14T18:35:44Z")

</div>

我好像把它弄好了？ 但在检查时，我上次做房产广告是 3 年前，当我再次尝试使其正常工作时，我无法让它们显示出来。奇怪。

---

<div class="post-metadata">

**Author:** ![becl](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@becl](https://meta.discourse.org/u/becl)\
**Post date:** [2025年四月14日 20:53 UTC](https://meta.discourse.org/t/house-ad-templates/122004/85 "2025-04-14T20:53:59Z")

</div>

谢谢告知。我现在也遇到了同样的问题，无法显示任何广告。

---

<div class="post-metadata">

**Author:** ![becl](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@becl](https://meta.discourse.org/u/becl)\
**Post date:** [2025年四月14日 20:57 UTC](https://meta.discourse.org/t/house-ad-templates/122004/86 "2025-04-14T20:57:06Z")

</div>

您好 Pfaffman，

我昨天回复您，询问我的 CSS 是否正确。我发布了 gemini 建议我使用的 CSS 和 HTML（但不起作用）。不确定为什么，但帖子被审核并删除，尽管该主题中其他人也发布了代码。

我还询问您是否有时间分享您用来使其正常工作的代码。不确定这是否是审核问题，但同样，其他人也发布了代码。

现在我的帖子被删除了，我不知道如何继续寻求帮助。我迷茫了！🤷‍♀️

---

<div class="post-metadata">

**Author:** ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)\
**Post date:** [2025年四月15日 13:11 UTC](https://meta.discourse.org/t/house-ad-templates/122004/87 "2025-04-15T13:11:13Z")

</div>

您好 @becl，我已经恢复了您那无法正常工作的 CSS 的帖子——请随时继续对话，并让我们知道进展如何！

---

<div class="post-metadata">

**Author:** ![becl](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@becl](https://meta.discourse.org/u/becl)\
**Post date:** [2025年四月15日 20:59 UTC](https://meta.discourse.org/t/house-ad-templates/122004/88 "2025-04-15T20:59:44Z")

</div>

非常感谢。我很感激。 🙂

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2025年六月27日 17:59 UTC](https://meta.discourse.org/t/house-ad-templates/122004/89 "2025-06-27T17:59:28Z")

</div>

> [@Discourse](#):
>
> ### 2. 响应式横幅广告 - 样式 1

这今天对我来说不起作用。文字在图像的右侧而不是顶部，我认为它应该在那里。也许过去 6 年里有什么变化？

一个很酷的版本将包含占位符，以便人们可以直接从这里获得一个包含所有内容的有效示例。

---

<div class="post-metadata">

**Author:** ![bck055](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@bck055](https://meta.discourse.org/u/bck055)\
**Post date:** [2026年一月2日 11:45 UTC](https://meta.discourse.org/t/house-ad-templates/122004/90 "2026-01-02T11:45:15Z")

</div>

如何开启“House Ads”标签页？

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/8/3/c83b408840282b0c1a866fa6ca7cc750f7cfb69d.png)

---

<div class="post-metadata">

**Author:** ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)\
**Post date:** [2026年一月5日 15:26 UTC](https://meta.discourse.org/t/house-ad-templates/122004/91 "2026-01-05T15:26:48Z")

</div>

这对我有效。请确保您的网络浏览器中没有启用任何广告拦截器。

---

<div class="post-metadata">

**Author:** ![bck055](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@bck055](https://meta.discourse.org/u/bck055)\
**Post date:** [2026年一月8日 03:16 UTC](https://meta.discourse.org/t/house-ad-templates/122004/92 "2026-01-08T03:16:53Z")

</div>

谢谢，我又看了一遍，可能是新的 Edge 阻止了它。

[上一頁](https://meta.discourse.org/t/house-ad-templates/122004.md?page=1)
