gpt4 book ai didi

html - 响应式 adsense 单元的最小高度

转载 作者:太空宇宙 更新时间:2023-11-04 11:22:50 24 4
gpt4 key购买 nike

我的页面上有一个响应式广告单元,出于某种原因,它的高度为 60 像素,而我确实需要它为 90 像素,并在屏幕变小时切换到 300x250。有什么办法可以控制吗?

附注这是非常标准的 adsense 代码

<div classs="adunit">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Pmember Resp1 -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-****"
data-ad-slot="*****"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>

它的css是

.adunit {max-width:730px}

我试过了

<ins class="adsbygoogle"
style="display:block;min-height:90px"

我试过了

.adunit {min-height:90px}

最佳答案

您正在使用智能调整(data-ad-format 属性)并且您可以控制总体形状...

... by changing the value of data-ad-format to one of these values: "rectangle", "vertical", "horizontal" or any combination of these separated by a comma, e.g., "rectangle, horizontal".

创建自适应广告单元/指定一般形状
https://support.google.com/adsense/answer/3543893

如果您想完全控制高度,您需要删除 data-ad-format 并使用 @media 查询:

<style type="text/css">
.adslot_1 { width: 320px; height: 100px; }
@media (min-width:500px) { .adslot_1 { width: 300px; height: 250px; } }
@media (min-width:800px) { .adslot_1 { min-width: 300px; max-width: 970px; width:100%; height: 90px } }
</style>
<ins class="adsbygoogle adslot_1"
style="display:inline-block;"
data-ad-client="ca-pub-1234"
data-ad-slot="5678"></ins>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

以上代码段是“指定可扩展宽度和固定高度”和“指定每个屏幕宽度的确切尺寸”的组合,来自 page I linked .

如果你想把这个单元放在页面的顶部,那么我想你会想要离开 .adslot_1 { width: 320px;高度:100px; } 按照我的建议编写代码,因为:

Is placing a 300x250 ad unit on top of a high-end mobile optimized page considered a policy violation?

Yes, this would be considered a policy violation as it falls under our ad placement policies for site layout that pushes content below the fold. This implementation would take up too much space on a mobile optimized site's first view screen with ads and provides a poor experience to users. Always try to think of the users experience on your site - this will help ensure that users continue to visit.

AdSense 政策常见问题解答/第 3 部分:移动相关
https://support.google.com/adsense/answer/3394713?hl=en#3

也许您会想看我写的关于使用 AdSense 查询 @media 的小教程:

为什么我们不应该在 AdSense ins 标记上使用@media 查询
https://productforums.google.com/forum/#!topic/adsense/TiihLH_gMnw

关于html - 响应式 adsense 单元的最小高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32619900/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com