css - 背景图像不固定在移动设备上
问题描述
我正在开发我的服装品牌店 (SHOPIFY) 并添加了背景图片。在桌面上它看起来很完美,正是我想要的。但是在移动设备上,图像会变形,即使图像上的 CSS 代码也会background-attachment: fixed;
随着产品和其他内容滚动。
这是我的完整代码:
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;
有人可以帮我吗?
解决方案
推荐阅读
- keras - 带有 POS 的 Word2Vec 没有产生预期的结果?
- powerquery - 如何拆分一行,其中每个单元格中有 2 个数据由回车分隔?
- angular - Angular HttpClient get 方法返回具有错误命名属性的对象
- python - 求解线性方程组,其中每个矩阵元素本身都是矩阵 (2D),每个变量都是 1D 向量
- tensorflow - 如何将滤镜转换回 RGB 值?
- javascript - 如何模拟文本字段的 inputRef
- laravel - 如何仅验证我通过获取请求获得的值的一部分?
- c++ - 将 x、y、z 转换为航向和角度
- javascript - Bug 问题:失败的道具类型:道具`onClick`在`Letter`中标记为必填,但其值为`undefined`
- apache - 从私钥生成 Apache 公钥