我有一个响应式Adsense广告单元,我想在我的响应式网站上作为我的页脚。我正在使用媒体查询,如Adsense文档中所述,以便在不同的屏幕宽度设置高度/宽度。
这是我的CSS:
<style>
@media (min-width: 320px) {
.adslot-desktop {
width: 320px;
height: 50px;
display: inline-block;
}
}
@media (min-width: 500px) {
.adslot-desktop {
width: 468px;
height: 60px;
display: inline-block;
}
}
</style>
这是我的HTML:
<ins class="adsbygoogle adslot-desktop"
data-ad-client="xxxxx"
data-ad-slot="xxxxxx"
data-ad-format="auto"></ins>
在屏幕宽度超过500px时,我得到预期的468x60广告。但是,低于500px,我得到的是320x100广告。
为什么它没有像我指定的那样给我320x50的广告?
答案 0 :(得分:2)
我认为您需要删除data-ad-format
,因为data-ad-format
智能大小调整:
我们根据的宽度动态计算所需的大小 广告单元的父容器,然后确定什么是最佳标准 高度与宽度一致。
关于自适应广告单元:
https://support.google.com/adsense/answer/3213689
您想要的是&#34;每个屏幕宽度的确切尺寸&#34;:
<style>
.adslot-desktop { width: 320px; height: 50px; }
@media (min-width: 500px) { .adslot-desktop { width: 468px; height: 60px; } }
</style>
<ins class="adsbygoogle adslot-desktop"
style="display:inline-block;"
data-ad-client="xxxxx"
data-ad-slot="xxxxxx"></ins>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
创建自适应广告单元&gt;高级&gt;每个屏幕宽度的确切大小:https://support.google.com/adsense/answer/3543893#adv