背景大小不适用于移动设备

时间:2017-11-03 17:33:34

标签: html css mobile

我真的不知道为什么会这样,我想我已经累了,但问题是"背景大小"当我尝试在我的电脑上使用的浏览器上进行模拟时,我的移动设备无法正常工作。

看看:

PC看起来像这样:Image

移动...... Image

啊!代码:



@media screen and (max-width: 888px) {
  body{background: url(../img/bgm.jpg) fixed no-repeat; background-size: cover;}
}




由于

2 个答案:

答案 0 :(得分:0)

给它一个旋转,只需将它添加到/ head /

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

信用:https://www.w3schools.com/css/css_rwd_viewport.asp

如果这没有解决问题,那么如果你有一个带有背景图片的div尝试包含而不是覆盖在移动版本上,或者只是上传具有相应图像的图像,那么它可能是你的背景位置大小大小,例如:如果标题是300px宽,150px高度,只需将图像调整为

答案 1 :(得分:0)

终于工作了!

经过深入搜索后,我发现了这一点:background: fixed no repeat not working on mobile

body:before {
  content: "";
  display: block;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: -10;
  background: url(photos/2452.jpg) no-repeat center center;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
相关问题