谷歌广告部分页面有时不显示广告内容,结果广告位置就空白了,很不美观,所以就有了这个方案,就相当于给广告位加了个背景,在广告无法显示时则就会显示广告招募中的文字内容。
实现
首先将广告代码放入如下div。
然后加入如下css即可,其中content属性的值就是文字内容,可以将中文转码后填入避免部分浏览器不兼容问题。
.zhaomu {
min-height: 100px;
text-decoration: none;
position: relative;
}
.zhaomu:before {
background: #bababa;
content: '\5e7f\544a\62db\52df\4e2d';
display: flex;
justify-content: center;
align-items: center;
height: 100%;
color: #fff;
font-size: 1.6rem;
text-decoration: none;
position: absolute;
width: 100%;
}