首页 > 解决方案 > 您如何调整谷歌广告的大小并将其保存在 DIV 中并使其不大于 DIV?

问题描述

我将展示广告作为我的谷歌广告单元(响应式)。我希望 google 生成的广告包含在 350x250 DIV 容器中。然而,目前,当谷歌生成一个 160x600 的广告时,即使我my-ad说 div 框应该是 350x250。我怎样才能解决这个问题?

.my-ad {
    max-height: 300px;
    max-width: 250px;
    min-height: 0px;
    min-width: 0px;
}
<div class="my-ad">
  <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
  <ins class="adsbygoogle"
       style="display:block"
       data-ad-client="ca-pub-CENSORED"
       data-ad-slot="CENSORED"
       data-ad-format="auto"
       data-full-width-responsive="true"></ins>
  <script>
       (adsbygoogle = window.adsbygoogle || []).push({});
  </script> 
</div>

标签: javascripthtmlcssadsense

解决方案


如果您希望您的插槽不大于 300x250,那么我觉得您不应该使用响应式。例如,在移动响应式广告上,全宽通常大于 300 像素。

您是否考虑过只投放固定尺寸的广告?例如像这样:https ://support.google.com/adsense/answer/9183363?hl=en


推荐阅读