Safari忽略了Modernizr CSS规则(Mobile Safari也是如此)

时间:2012-10-14 06:15:12

标签: css safari mobile-safari modernizr

我无法弄清楚为什么Safari / Mobile Safari会忽略使用Modernizr的.generatedcontent规则使用icomoon隐藏图标的一行代码。您可以在http://importbible.com/的页面页脚上查看图标。浏览器在Chrome上完美呈现。做了一些测试,Safari 5.1.2在Safari 6.0.1工作时失败了。 iPad运行4.3失败。有问题的一行是:

.generatedcontent .icon-gplus, .generatedcontent .icon-facebook, .generatedcontent .icon-twitter, .generatedcontent .icon-feed, .generatedcontent .icon-youtube, .generatedcontent .icon-flickr, .generatedcontent .icon-deviantart, .generatedcontent .icon-tumblr, .generatedcontent .icon-share, .generatedcontent .icon-tag, .generatedcontent .icon-home, .generatedcontent .icon-news, .generatedcontent .icon-cart, .generatedcontent .icon-cart, .generatedcontent .icon-basket, .generatedcontent .icon-mail, .generatedcontent .icon-clock, .generatedcontent .icon-forward, .generatedcontent .icon-replay, .generatedcontent .icon-chat, .generatedcontent .icon-refresh, .generatedcontent .icon-magnifier, .generatedcontent .icon-zoomin, .generatedcontent .icon-expand, .generatedcontent .icon-cog, .generatedcontent .icon-trash, .generatedcontent .icon-list, .generatedcontent .icon-grid, .generatedcontent .icon-download, .generatedcontent .icon-globe, .generatedcontent .icon-link, .generatedcontent .icon-attachment, .generatedcontent .icon-eye, .generatedcontent .icon-star_empty, .generatedcontent .icon-star_half, .generatedcontent .icon-star, .generatedcontent .icon-heart, .generatedcontent .icon-thumb, .generatedcontent .icon-cancel, .generatedcontent .icon-left, .generatedcontent .icon-right { display: none !important; }

3 个答案:

答案 0 :(得分:3)

将其作为调试选项抛出,如果没有别的话。 您是否尝试过使用.icons的通配符?

[class*='icon-'] { display:none !important }

[class^='icon-'] { display:none !important }

编辑: 星期五你的页面超时,所以我无法查看。今天我收到以下错误(Safari 5.1.2 / MAC):

  1. XMLHttpRequest无法加载 http://static.ak.fbcdn.net/rsrc.php/v2/yy/r/5SjacuFVbni.js。起源 {}不允许http://www.facebook.com 访问控制允许来源。的OAuth
  2. 无法加载资源: 服务器响应状态为407(代理验证 必填)//这可能就在我身边。
  3. 我在“连接”下看到6个图标。

    我可以直接浏览错误行#1中的URL(Safari或Chrome)。

答案 1 :(得分:1)

<span class="icon-facebook">1</span>似乎是您不支持生成内容的浏览器的备份。我建议默认隐藏备份(通过CSS),并让javascript显示不支持生成内容的浏览器的备份图标。要么使用Modernizr的“no-generatedcontent”类,要么使用IcoMoon提供的IE7 javascript文件。

使用Modernizr:

.icon-facebook { display: none; }
.no-generatedcontent .icon-facebook {display: inline; }

或IcoMoon提供的lte-ie7.js文件。使用此方法您不必使用额外的标记(仅使用<span class="icon-facebook-b">而不使用备份<span class="icon-facebook">1</span>)。

/* Use this script if you need to support IE 7 and IE 6. */

window.onload = function() {
    function addIcon(el, entity) {
        var html = el.innerHTML;
        el.innerHTML = '<span style="font-family: \'icomoon\'">' + entity + '</span>' + html;
    }
    var icons = {
            'icon-home' : '&#x21;',
            'icon-home-2' : '&#x22;',
            'icon-newspaper' : '&#x23;',
            'icon-pencil' : '&#x24;',
            'icon-pencil-2' : '&#x25;'
        },
        els = document.getElementsByTagName('*'),
        i, attr, html, c, el;
    for (i = 0; i < els.length; i += 1) {
        el = els[i];
        attr = el.getAttribute('data-icon');
        if (attr) {
            addIcon(el, attr);
        }
        c = el.className;
        c = c.match(/icon-[^\s'"]+/);
        if (c) {
            addIcon(el, icons[c[0]]);
        }
    }
};

答案 2 :(得分:0)

现在Chrome显示页脚社交图标很好,但在Safari 5.1.7中根本没有图标。

我注意到的另一件事是几个CSS文件被应用了两次(缩小和简单)。见第73行:

<link rel='stylesheet' type='text/css' media='screen' href="http://importbible.com/wp-content/plugins/bwp-minify/min/?f=wp-content/themes/import_bible_5.3/css/bs-responsive.css,wp-content/themes/import_bible_5.3/css/rating.css,wp-content/themes/import_bible_5.3/style.css&amp;f22064" />

第420-422行:

<link rel='stylesheet' id='bootstrap-rs-css'  href="http://importbible.com/wp-content/themes/import_bible_5.3/css/bs-responsive.css?f22064" type='text/css' media='screen' />
<link rel='stylesheet' id='rating-css'  href="http://importbible.com/wp-content/themes/import_bible_5.3/css/rating.css?f22064" type='text/css' media='screen' />
<link rel='stylesheet' id='style-css'  href="http://importbible.com/wp-content/themes/import_bible_5.3/style.css?f22064" type='text/css' media='screen' />

看起来Safari在这个特殊问题上变得疯狂。