【问题标题】:Fixed Background Image for Mobile with CSS使用 CSS 修复了移动设备的背景图像
【发布时间】:2014-04-29 07:29:11
【问题描述】:

使用 @media 和 CSS 来修复背景图像。逻辑告诉我这应该可以工作,但是在实施后我没有得到任何改变的结果。我也包含了我正在努力覆盖的body 代码。

手机:

@media (min-width: 768px) {
   body {
     background-position: center;
     background-attachment: fixed;
   }
}

桌面:

body {
   height: 100%;
   background-image: url('../design/image.jpg');
   background-repeat: no-repeat;
   background-color: #333;
   background-position: center;
   background-size: cover;
}

【问题讨论】:

    标签: html css


    【解决方案1】:

    background-attachment: fixed; 不适用于移动 webkit。有一个解决方法,你可以将图片内联在html中,设置位置固定和内容下方的z-index。

    这是相关的Using background-attachment:fixed in safari on the ipad

    【讨论】:

    • 这让我得到了我需要的东西。谢谢-
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-30
    • 2016-10-10
    • 2012-12-11
    • 2014-06-28
    • 1970-01-01
    相关资源
    最近更新 更多