首页 > 解决方案 > 背景图像不固定在移动设备上

问题描述

我正在开发我的服装品牌店 (SHOPIFY) 并添加了背景图片。在桌面上它看起来很完美,正是我想要的。但是在移动设备上,图像会变形,即使图像上的 CSS 代码也会background-attachment: fixed;随着产品和其他内容滚动。

网站:www.hyghassociation.org

这是我的完整代码:

    body,
html {
  background: url({{ 'background.jpg' | asset_url }});
    background-color: #000;
    -webkit-background-size: contain;
    -moz-background-size: contain;
    -o-background-size: contain;
    background-size: contain;
    background-position: center;
    background-attachment: fixed;
}
  @media only screen and (max-width: 749px) {
body {
    
    background: url({{ 'mobile_background.png' | asset_url }});
    -webkit-background-size: contain;
    -moz-background-size: contain;
    -o-background-size: contain;
    background-size: 100% 100%;
    background-position: center;
    background-attachment: fixed;

有人可以帮我吗?

标签: cssshopify

解决方案


推荐阅读