我已经使网站具有响应性,并用Adsense响应式广告单元替换了这些广告单元。
我现在的问题是,Adsense现在提供2 x(300×600)广告单元。 Adsense TOS状态:每个网页只能投放1(300×600)个广告单元
最大宽度显然会被adsense响应式广告单元吸引。
但是,当我尝试并将父div的最大高度设置为250像素时,为了限制每页300×600的广告数量,max-height将被忽略,adsense仍然会显示300×600
有其他人遇到此问题,如果是,您是如何设置响应式广告单元的最大高度的?
提前致谢,
Kes
解决方法
我认为你不应该在父div上定义height(max-height)。
广告高度(由广告尺寸自动调整)由adsbygoogle.js决定(如果您想控制广告高度,则需要使用data-ad-format(“rectangle”,“vertical”,“horizontal” “矩形,水平”)。
或者(不推荐),您可以“降级”广告代码(通过删除data-ad-format属性),然后使用@media查询指定确切的大小。 (见Exact size example.)
EDIT – Google更新了“About responsive ad units”页面上的“技术注意事项”部分。
There are some situations in which you’ll need to take extra action to
make a responsive ad unit work correctly:…
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 07004.