我已经尝试了两天,以使背景 img 响应移动设备。这是一个很长的主页(大约 8000 像素)。整个页面的内容有一个div父级“background_div”。我都尝试过,大小封面或包含标签,img 得到了像素化,就像它会被放大一样,内容是响应式的,但背景 img 让我头疼。我需要它来识别设备宽度、缩小并保持固定而不是沿着 8000 像素长的页面拉伸。任何人都可以告诉我这里有什么问题吗?
#background_div {
background-image: url('home.jpg');
background-repeat: no-repeat;
background-position: center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-attachment: fixed;
}
/*It just won't scale to the divice width and height*/
<div id="background_div">