【问题标题】:How to restrict height of Google responsive Ads?如何限制谷歌响应式广告的高度?
【发布时间】:2022-06-11 20:46:19
【问题描述】:

我想在桌面上制作限制为 90-250 像素高度和 250-1280 像素宽度的自适应广告。

所以,我查看了official Google documentation 并创建了如下广告代码。

<ins class="adsbygoogle"
   style="display:inline-block;min-height:90px;max-height:250px;min-width:250px;max-width:1280px;width:100%;height:100%"
   data-ad-client="ca-pub-0000"
   data-ad-slot="000"></ins>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-000" crossorigin="anonymous"></script>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

但是,使用此代码,仅显示 90 像素 x 1280 像素的广告。

所以我回到自适应广告并为广告添加了一个类来限制高度。

<ins class="adsbygoogle testad"
     style="display:block"
     data-ad-client="ca-pub-333"
     data-ad-slot="333"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>


.testad{
max-height:250px !important;
}

在这种情况下,Google Ads 会覆盖高度限制。

将展示宽度:100%,高度:280px 的广告。

谁能告诉我我做错了哪一部分?

谢谢

【问题讨论】:

    标签: html css adsense


    【解决方案1】:

    尝试这些方法。所以标准尺寸是 90 像素,但是当屏幕最小为 1280 像素时,使用大的。希望您知道如何根据自己的喜好整理它。

    <style>
    .adsiz { width:90px; height: 250px; }
    @@media screen and (width:1280px) { width:1280px; height:250px}
    </style>
    
    <div class="adsiz">
    <ins class="adsbygoogle" data-ad-client="ca-pub-0000"data-ad-slot="000">/ins></div>
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-000" crossorigin="anonymous"></script>
    <script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
    

    【讨论】:

      猜你喜欢
      • 2021-11-29
      • 2015-12-14
      • 2011-10-16
      • 1970-01-01
      • 2021-04-14
      • 2013-11-30
      • 1970-01-01
      • 2022-06-17
      • 2014-04-24
      相关资源
      最近更新 更多