响应式adsense广告单元覆盖其div [英] Responsive adsense ad unit go over its div

查看:226
本文介绍了响应式adsense广告单元覆盖其div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google表示,自适应广告会根据所提供空间的宽度和高度动态填充可用空间:

According to Google, responsive ads fill the available space dynamically according to the width and height of that provided space:


我们计算根据广告单元​​的父容器的宽度动态生成所需的尺寸,然后根据该宽度确定最佳标准高度。

"We calculate the required size dynamically based on the width of the ad unit’s parent container, then determine what's the best standard height to go with that width."

我在div中放置了响应式Adsense单位,宽度值为774像素。这里是div css代码:

I placed a responsive Adsense unit in a div that has a width value of 774px. Here is the div css code:

.content-left{
display:table-cell;
width:774px;
max-width:774px;
vertical-align:top;
padding-left:10px;
padding-right:10px;
height:500px;}

问题是,adsense单元越过div覆盖右侧div的内容,如下图所示。

The problem is that the adsense unit go over that div and cover the content of the div on the right like shown in the following image.

Adsense单元的宽度实际上大约为1100像素。我使用响应式广告,以便广告可以根据屏幕大小调整大小。如果用户在他们的智能手机上浏览我的网站,显然广告的大小会相应地改变。

The adsense unit is actually taking about 1100px in width. I use responsive adsense so that ads can resize according to the screen size. If a user browse my site on their smartphone, obviously the ad's size changes accordingly.

在我试图解决问题,我添加了一个新的div在左div,将adsense代码放入其中,并设置最大宽度如下:

In my attempt to solve the problem, I added a new div inside the left div and put the adsense code in it and set the maximum width as follows:

.adsenseOnLeft{
max-width:774px;

}

issue和adsense单元仍然占用比它的父div更多的空间。

That did not solve the issue and adsense unit is still taking more space than its parent div. So how can I make its width not go over the width of the div it is placed inside?

更新:这个问题只发生在chrome浏览器。当我刷新页面,单位尊重它的父div,不会超过它。它只有当我第一次浏览到任何页面。
我在Internet Explorer中检查它,该单元保持在它的容器内,并按照它的工作。

Update: The issue is happening only in chrome browser. When I refresh the page, the unit respect it's parent div and doesn't go over it. It only does that when I first browse to any page. I checked it in Internet Explorer, the unit stays inside it's container and working as it suppose it.

推荐答案

您尝试添加浮点和宽度?

Have you tried adding a float and a width?

.adsenseOnLeft
{
  float: left;
  width:100% !important;
}

这篇关于响应式adsense广告单元覆盖其div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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