【发布时间】:2015-11-27 14:27:58
【问题描述】:
我正在为我的客户制作一个网站。
现在,该网站的登录页面上有背景图片,在所有 PC 浏览器中看起来都非常漂亮,但有一个问题......
如果您不使用谷歌浏览器,在所有平板电脑和手机上,它会使背景图像看起来非常放大,而且很奇怪。
有代码(css background-image,应该是响应式的,但是很多浏览器没有):
body {
height: 100%;
font-family: 'Open Sans';
font-weight:100;
color:#666666;
line-height: 1.7em;
/* Location of the image */
background-image: url(1.jpg);
/* Background image is centered vertically and horizontally at all times */
background-position: center center;
/* Background image doesn't tile */
background-repeat: no-repeat;
/* Background image is fixed in the viewport so that it doesn't move when
the content's height is greater than the image's height */
background-attachment: fixed;
/* This is what makes the background image rescale based
on the container's size */
background-size: cover;
/* Set a background color that will be displayed
while the background image is loading */
background-color: #464646;
}
【问题讨论】:
-
平板电脑往往具有相当高的像素密度,因此您的图像可能分辨率太低而看起来不太好。您可能需要为我们定义“奇怪”。