html - Safari 不会在 <div> 中显示背景图像

标签 html css twitter-bootstrap

我似乎无法在 Safari 中显示背景图像。它适用于 IE 和 Chrome。我尝试了几个带有 -webkit 前缀的替代方案,但没有成功。

    <style type="text/css">

        h1, h2, h3, h4, p {position: relative; z-index: 10;}

        .jumbotron {
            position: relative;
            z-index: 3;
        }

        .jumbotron:after {
            background: linear-gradient(rgba(255,255,255,1), rgba(255,255,255,.5)), url('img/carousel_island.png');
            bottom: 0;
            content: "";
            display: block;
            left: 0;
            position: absolute;
            right: 0;
            top: 0;
            z-index: 2;
        }


    </style>

这是 HTML:

    <!-- Main jumbotron for a primary marketing message or call to action -->
    <div class="jumbotron">
        <div class="container">
            <h1><strong>Welcome to Pepi's Island</strong></h1>
            <h3><strong>A place for kids to emotionally and socially learn and grow.</strong></h3>
            <br>
            <p><a class="btn btn-success btn-lg">Learn more &raquo;</a></p>
        </div>
    </div>

最佳答案

Safari 在使用简写 background 样式时存在一些已知的错误;作为单独 CSS 样式支持的某些功能在单个 background 样式中一起使用时将无法工作。

我不确定您在这里使用的样式是否会受到影响,但值得一试(我知道它会影响 background-sizing 等)。

因此,我建议将您的 background 样式拆分为单独的样式:

background-color: linear-gradient(rgba(255,255,255,1), rgba(255,255,255,.5));
background-image: url('img/carousel_island.png');

希望有帮助。

关于html - Safari 不会在 <div> 中显示背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18519374/

相关文章:

html - 在 Bootstrap 3 中将文本显示在与 block 级按钮相同的行上

javascript - 如何使用JS在div标签中动态显示值

javascript - jQuery 计数器不工作

android - 如何在 Android webview 中制作一个正方形大小的 HTML 表格填充屏幕

html - CSS 和 HTML 定位说明

javascript - 全局onBlur/onFocus

html - 使用 Bootstrap 将 CheckBox 右对齐

html - 动态图像缩放

html - 调整浏览器大小时选项卡中断

javascript - 避免 Javascript 中的重复代码 : many buttons for playing audios