设置 Adsense 自适应广告单元的最大高度 [英] Set max height of Adsense responsive ad unit

查看:51
本文介绍了设置 Adsense 自适应广告单元的最大高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站右侧栏中有 2 x (300x250) 个 Adsense 广告单元

I had 2 x (300x250) Adsense ad units in the right side bar of my site

我已将网站设为自适应,并将这些广告单元替换为 Adsense 自适应广告单元.

I have made the site responsive and replaced these ad units with Adsense responsive ad units.

我现在遇到的问题是 Adsense 现在提供 2 x (300x600) 个广告单元.Adsense TOS 规定每页只能投放 1 个 (300x600) 广告单元

The problem i now have is that Adsense is now serving 2 x (300x600) ad units. Adsense TOS state that you can only serve 1 (300x600) ad unit per page

Adsense 响应式广告单元显然会占用最大宽度.

The max width is obviously getting picked up by adsense responsive ad units.

但是当我尝试将父 div 的最大高度设置为 250 像素以限制每页 300x600 广告的数量时,最大高度被忽略,而 adsense 仍然显示 300x600

But when I try and set the max-height of the parent div to 250px, to limit the number of 300x600 ads per page, the max-height gets ignored and adsense still displays a 300x600

有没有其他人遇到过这个问题?如果有,您是如何设置自适应广告单元的最大高度的?

Has anyone else encountered this problem and if so, how did you manage to set the max-height of the responsive ad unit?

提前致谢,

凯斯

推荐答案

您可以将 data-ad-format="auto" 更改为 data-ad-format="rectangle".(请参阅高级功能 > 水平形状示例.)

You could change data-ad-format="auto" to data-ad-format="rectangle". (See Advanced features > Horizontal shape example.)

我认为你应该在父div上定义height(max-height).

I think you should not define height (max-height) on parent div.

广告高度由 adsbygoogle.js(即智能 尺寸调整)(自动)确定,如果您想控制广告高度,您可以需要使用 data-ad-format(矩形"、垂直"、水平"或您的首选组合,例如矩形,水平").

Ad height is (automatically) determined by adsbygoogle.js (that is smart sizing) and if you want to control ad height you need to use data-ad-format ("rectangle", "vertical", "horizontal" or your preferred combination like "rectangle,horizontal").

或者(不推荐)您可以降级"广告代码(通过删除 data-ad-format 属性),然后指定确切尺寸(s) 带有 @media 查询.(请参阅确切尺寸示例.)

Or (not recommended) you could "downgrade" the ad code (by removing data-ad-format attribute) and then specify the exact size(s) with @media queries. (See Exact size example.)

编辑 - Google 更新了关于关于响应式的技术注意事项"部分广告单元"页面.

EDIT - Google updated "Technical considerations" section on "About responsive ad units" page.

在某些情况下,您需要采取额外措施使自适应广告单元正常工作:

There are some situations in which you’ll need to take extra action to make a responsive ad unit work correctly:

...

父容器具有固定或有限的高度.自适应广告不应放置在高度固定或有限的容器内,因为它们在某些设备或浏览器上可能更高.如果你需要限制响应式广告的高度,您需要修改您的代码并使用 CSS 媒体查询来设置父级的高度容器.了解如何修改自适应广告单元.

The parent container has fixed or limited height. Responsive ads should not be placed inside containers with a fixed or limited height, as they may be taller on some devices or browsers. If you need to limit the height of your responsive ads, you’ll need to modify your code and use CSS media queries to set the height of the parent container. Find out how to modify your responsive ad unit.

这篇关于设置 Adsense 自适应广告单元的最大高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆