谷歌AdSense广告匹配不到显示空白时用CSS隐藏或替换为图片美化
更新:2023-02-07 18:27:12
人气:676
来源:本站原创
A+
谷歌AdSense广告经常会出现匹配不到的时候,出现此种情况后会直接占位成空白,页面效果上看非常不好看,所以通过官方的介绍可以用CSS隐藏或替换成占位图片的链接。
Google 官方推荐使用 CSS,在广告代码中属性有使用 data-ad-status 来指示广告展示位置是否已填充,可以定位到应用 CSS 来隐藏元素。
ins.adsbygoogle[data-ad-status="unfilled"] {
display: none !important;
}
方案一:增加一个图片链接,如果广告未填充显示出来就用指定的图片显示占位
<div style="width:920px; height:auto; clear:both; margin:5px auto; text-align: center">
<ins class="adsbygoogle"
style="display:inline-block;width:880px;height:110px"
data-ad-client="ca-pub-746454xxxxx"
data-ad-slot="5151889170">
<a href="https://www.mdaima.com" target="_blank" class="zhanwei_a"><img src="/images/ad/ad_2.gif" style="width:880px; height:125px;"></a>
</ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<style>
ins.adsbygoogle .zhanwei_a {
display: none !important;
}
ins.adsbygoogle[data-ad-status="unfilled"] .zhanwei_a {
display: block !important;
}
</style>
方案二:如果广告未显示出来就直接隐藏
<div class="art_ad_w2" style="width:920px; height:auto; clear:both; margin:10px auto; text-align: center;">
<!-- 文章底部 -->
<div class="left_column">
<ins class="adsbygoogle w_2"
style="display:inline-block;width:880px;height:110px"
data-ad-client="ca-pub-746454xxxxx"
data-ad-slot="5151889170"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
<style>
ins.w_2[data-ad-status="unfilled"] {
display: none !important;
}
</style>
推荐的文章
随手记
- ● 自制(IP或域名)可信任的SSL证书,适用360、chrome等浏览器
- ● windows系统下php无法使用curl怎么办?
- ● 绿联UGREENKVM切换器(分屏器)快捷键丢失解决办法
- ● 统信UOS开机指定网址全屏启动自带浏览器以及屏蔽ALT+F4关闭
- ● xshellSSH连接Linux服务器防止超时退出
- ● php8开启OpenSSL扩展库报错disabledinstallext
- ● 统信系统linux安装php时的报错libxml-2.0>=2.7.6
- ● tidb关闭sql_mode=ONLY_FULL_GROUP_BY模式
- ● windows10如何开机自动运行bat文件
- ● Win10Mysql8初始密码丢失,初始化又不显示密码
PHP经验分享
- ● PHP批量对TCP服务端指定多个IP非阻塞检查在线状态
- ● python实现TCP服务端持续接收关机、重启指令并输出结果【系列三】
- ● PHP给TCP服务端发送指令【系列二】
- ● PHP判断TCP服务端是否在线【系列一】
- ● PHP判断远程文件是否存在
- ● LINUX下用PHP获取CPU型号、内存占用、硬盘占用等信息代码
- ● PHP代码用UDP方式远程唤醒电脑让计算机开机
- ● apache下php生成验证码图片不能显示
- ● PHP使用AES加密解密示例(无偏移)
- ● Pluginmysql_native_passwordreported:''mysql_native_password'isdeprecate问题