【问题标题】:How to fill the Background in Mobile with an image如何用图像填充手机背景
【发布时间】:2017-06-18 17:56:02
【问题描述】:

我尝试将图像作为背景。 在桌面上它工作得很好,但是当我尝试使用我的手机时它不起作用。我不明白为什么,因为我将封面设置为背景尺寸,而在移动设备上它应该覆盖所有空间。

这是代码:

CSS

body { 
    background-image: url('/nutickets/images/bluenight.jpg');
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    background-position: center center;
}

HTML

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" href="/nutickets/style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>

<body>

</body>

</html>

我手机上的图片:

如果我使用 Chrome 的 Toogle 设备工具栏检查一切正常,但是当我尝试使用我的智能手机时却无法正常工作。我刷新了缓存,我尝试隐身,我尝试使用不同的移动浏览器但没有。

【问题讨论】:

  • 你能添加你的图片吗?我检查你的代码它工作正常。
  • 我用手机截图编辑了答案,我刷了现金,尝试了一个隐身窗口和不同的浏览器。

标签: html css responsive-design background


【解决方案1】:

这在我的 android 设备上对我有用 - 尝试强制 html 元素覆盖设备的整个高度:

html {
    min-height: 100%;
}

【讨论】:

  • 现在它可以工作但我没有得到它,因为我必须使用 min-height: 100% fo the html
猜你喜欢
  • 1970-01-01
  • 2016-02-12
  • 2019-01-28
  • 2011-12-26
  • 2018-10-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-28
相关资源
最近更新 更多