html - 如何在 Safari 浏览器中将背景颜色拉伸(stretch)到视口(viewport)的左侧和右侧

标签 html css safari background-color

我在 http://bit.ly/1gH5Nqw 有一个网站在页面中间的内容 block 后面有一个白色背景。在除 Safari 之外的所有浏览器中,白色背景延伸到视口(viewport)的左右边缘。有谁知道为什么或如何解决这个问题?

这是我的 CSS:

div#maincontentcontainer div#home-services-block,
div#maincontentcontainer div#inner-page-content {
    background-color: #fff; /* trying to get background to appear in Safari browser */
    margin-top: 60px;
    position: relative; /* to get the container to extend to the screen/viewport margins */
    }
    div#maincontentcontainer div#home-services-block:after,
    div#maincontentcontainer div#inner-page-content:after { /* to get the container to extend to the screen/viewport margins (http://stackoverflow.com/questions/28565976/css-how-to-overflow-from-div-to-full-width-of-screen) */
        content: "";
        position: absolute;
        height: 100%;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 100vw;
        background-color: #fff; /* changed `background:` to `background-color:` to see if white background would appear in Safari browser -- it did not */
        z-index: -1;
    }

适用于除 Safari 以外的所有现代浏览器: enter image description here

在 Safari 中不起作用: enter image description here

最佳答案

这就是问题所在。 maincontentcontainer 有一个名为 home background 的类,具有以下属性。我认为问题是 100% auto。需要删除该类或需要更改图像。图像是一个蓝色的大图像!

div#maincontentcontainer.home-background {
         background: url('/wp-content/themes/investorcom-2015/images/home-background.png') no-repeat center top;
         background-image: url(http://investor-com.com/wp-content/themes/investorcom-2015/images/home-background.png);
         background-size: 100% auto;
    }

关于html - 如何在 Safari 浏览器中将背景颜色拉伸(stretch)到视口(viewport)的左侧和右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32059253/

相关文章:

html - 具有不透明度值的悬停背景和具有不同不透明度值的悬停按钮

python - Python 中的网页抓取动态内容

javascript - 返回的 JavaScript 值不会在 div 元素内呈现

html - 使容器在包裹时收缩以适合子元素

javascript - 一个特定的类应该通过 <div> 显示溢出 :hidden property

ios - iPad 找不到主页书签的 apple-touch-icon.png

javascript - Mobile Safari 上的惯性滚动事件

Web 应用程序中 Javascript 绑定(bind)的用户交互元素 : a or button?

javascript - 如何在激活外部 div 时禁用底层 div 上的所有内容

javascript - Angular2 PWA/Safari 无法在新窗口中打开链接