Html 谷歌图片广告在母公司部门之外
我侧边栏中的谷歌广告延伸到父div之外,与其他内容重叠 以下是我遇到的问题的屏幕截图: Google Adwords代码在包含在中的中定义,具有“侧栏”id:Html 谷歌图片广告在母公司部门之外,html,css,Html,Css,我侧边栏中的谷歌广告延伸到父div之外,与其他内容重叠 以下是我遇到的问题的屏幕截图: Google Adwords代码在包含在中的中定义,具有“侧栏”id: <div id="sidebar"> <div> <h3>Categorías</h3> [categories defined here] </div> <div> <script as
<div id="sidebar">
<div>
<h3>Categorías</h3>
[categories defined here]
</div>
<div>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
[rest of google adwords code here]
</div>
</div>
我试着在#sidebar
div中添加'overflow:hidden'
,但也不起作用,谷歌广告被裁剪了,但我希望它适合侧边栏
我需要做什么更改才能使广告适合其父div?如果看不到将元素放置在侧边栏中的css,我猜您的广告位置设置为浮动,因为它不包含在侧边栏div中 在这种情况下,您需要实现: 1。在CSS中创建clearfix类: 添加以下CSS(注意:它适用于IE8及更高版本。如果需要支持旧浏览器,请查看上面的链接) 2。将clearfix应用于HTML: 将clearfix类添加到保存广告的div中:
<div id="sidebar">
[...]
<div class="clearfix">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
[rest of google adwords code here]
</div>
</div>
[...]
[此处是谷歌adwords的其余代码]
注意:
浮动的可能不是div,在这种情况下,您需要使用元素检查器检查元素。您不能将类添加到属于Google广告的元素中,因此您可以更改CSS规则以使用浮动元素的类名或ID
参考:
Clearfix:你给我指出了正确的方向!我必须使用你建议的类,但在包含类别的div中,而不是在包含谷歌广告的div中。。。非常感谢。很高兴我能帮忙!正如我所说,在没有看到代码的其余部分的情况下,我无法分辨出是哪个,但我知道它是其中之一:-)
.clearfix:after {
content: "";
display: table;
clear: both;
}
<div id="sidebar">
[...]
<div class="clearfix">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
[rest of google adwords code here]
</div>
</div>