Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 如何仅在移动设备上显示响应性adsense广告_Css_Mobile_Desktop_Adsense - Fatal编程技术网

Css 如何仅在移动设备上显示响应性adsense广告

Css 如何仅在移动设备上显示响应性adsense广告,css,mobile,desktop,adsense,Css,Mobile,Desktop,Adsense,我正在寻找一种正确的实现方法,在手机和台式机上显示/隐藏我的adsense广告 现在我正在使用这个当前的方法,它给了我们两个控制台错误 目前的方法是: 我们使用两个类mobileShow和mobileno来根据我们想要显示的位置标记广告 因此,如果我们想在手机上显示响应的adsense代码,我们就使用mobileshow,如果我们想在手机上隐藏大矩形广告,我们就使用mobileno 我们使用的代码如下所示: .mobileShow {display: none;} .mobileShow {di

我正在寻找一种正确的实现方法,在手机和台式机上显示/隐藏我的adsense广告

现在我正在使用这个当前的方法,它给了我们两个控制台错误

目前的方法是:

我们使用两个类mobileShow和mobileno来根据我们想要显示的位置标记广告

因此,如果我们想在手机上显示响应的adsense代码,我们就使用mobileshow,如果我们想在手机上隐藏大矩形广告,我们就使用mobileno

我们使用的代码如下所示:

.mobileShow {display: none;}
.mobileShow {display: inline;}
   @media only screen
   and (min-device-width : 320px)
   and (max-device-width : 480px)

.mobileno{display:none;}
   @media (max-width: 767px)
据我们所知,谷歌adsense策略允许显示:如果是用于实现响应式布局,则无显示

我们的问题是,我们在chrome开发控制台中收到以下错误2次:

2 x未捕获错误:找不到宽度为0px且数据广告格式为auto adsbygoogle.js:41的容器的响应大小

我们已经测试了好几次,我们知道上面的代码有问题

我们正在寻找一种无错误地实现当前解决方案的方法


如果有人能帮助我们,我们将不胜感激。

我也对完全自动广告大小的结果感到不满意,在一次分割测试后,我发现为响应性广告设置特定大小更有帮助,同时又不会影响性能

AdSense给出了一个例子,我只是用你的数据进行了调整

<style type="text/css">
.adslot_1 { display: none; }
@media (min-width:320px) { .adslot_1 { width: 320px; height: 50px; } }
@media (min-width:480px) { .adslot_1 { display: none; } }
</style>
<ins class="adsbygoogle adslot_1"
    style="display:inline-block;"
    data-ad-client="ca-pub-1234"
    data-ad-slot="5678"></ins>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

这可能是未来读者的有用信息:

找不到宽度为0px且数据广告格式为auto的容器的响应大小。当我在当前站点上禁用AdBlock Plus,但未在所有位置禁用时,我从响应AdSense广告中得到一个错误


只要我检查Disabled everywhere,AdSense错误就会停止显示,响应的AdSense广告就会正确显示。

我认为您的代码可能是正确的,但可能需要稍作更改。 通过改变

最小设备宽度:320px

最大设备宽度:480px


如果我没有弄错的话,adsense给了出版商两个选择;responsive和custom and responsive在移动设备上运行得非常好,虽然adsense允许进行定制。我们的adsense移动应用实现了更好的利润,这可能是因为对于宽度为0px的容器,找不到响应大小,这意味着adsense不支持您插入的格式。你的移动测量是什么?你所说的移动测量是什么意思?我通过上面的css声明屏幕的大小。adsense有特定的广告大小。广告大小格式=测量,对不起,对吗?一种习惯,一种回应。我通常使用响应式广告格式来处理这个问题,当我在手机或平板电脑上尝试时,一切都很好。所以,我不需要定制。
and (min-width : 320px)
and (max-width : 480px)