【问题标题】:IE8 doesn't load background-imageIE8 不加载背景图片
【发布时间】:2014-08-05 22:20:30
【问题描述】:

IE8 不会在 div 上显示背景图片。

我的 HTML:

<section class="section-divider textdivider divider1">
            <div class="container">
                <h1>Info About The Foundation</h1>
                <hr>
                <p>Microfestival stable energy fields natural homebirth sarong watsu, aura discovering valuable truths. Nature equinox forest, feline acupuncture salvia. Didgeridoo prius what the planet really needs, divine feminine compostable toilet change agent closing circle feeling deep gratitude sustainable rain dance prayerformance. Beltane perineum cuddle party, bioneers radiant.</p>
                <a href="about.html" class="btn btn-success">More About The Foundation</a>
            </div>
</section>

我的 CSS:

.divider1 {
    background-image: url('../images/bg/divider1.jpg')
}

在 IE8 中甚至无法加载图像。它只显示文本,根本没有使用任何样式。是因为 IE8 无法读取 div 的图像吗?我环顾四周,没有看到任何迹象表明 IE8 无法做到这一点。

【问题讨论】:

    标签: css internet-explorer internet-explorer-8


    【解决方案1】:

    请记住,&lt;section&gt; 是一个新的 HTML5 元素,这意味着 IE8 不会自动识别它。您是否 A) 添加了 html5shiv 并 B) 在 CSS 中设置了 display 属性?

    HTML5Shiv

    <!--[if lt IE 9]>
    <script>document.createElement("section");</script>
    <![endif]-->
    

    CSS

    section { display:block; }
    

    90% 的情况下,我的新项目无法在 IE8 上运行的原因是因为我忘记添加这两个。

    【讨论】:

    • 是的,我有一个 shiv 只是没有添加 css 部分,谢谢。
    • 嗯。这个每次都能吸引我。在 SublimeText 中,我已经开始将 shiv 和 css 添加到我的样板文件中,因为我肯定会忘记它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-29
    • 1970-01-01
    • 2016-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-17
    相关资源
    最近更新 更多