html - 背景图像未拉伸到页面底部:无法使用背景附件
问题描述
我正在开发一个需要完全覆盖整个页面的背景图像的项目。我无法使用属性“背景附件:封面”,因为该页面还需要在不支持背景附件的 iOS 上查看。
.sky-background {
background-image: url("https://images.unsplash.com/photo-1514477917009-389c76a86b68?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80");
background-position: center;
background-size: cover;
background-repeat: no-repeat;
/* cannot use this property */
/* background-attachment:fixed; */
}
<body class="sky-background">
</body>
我一直在寻找用于 iOS 的替代品,但到目前为止我还没有找到任何令人满意的东西。任何人都可以提供任何指示吗?
解决方案
这与文档高度有关。尝试body {min-height: 100vh;}
或更好html {100%};
。
推荐阅读
- configuration - 如何更改 zpool 的默认 zfs 选项?
- javascript - TypeScript:使用动态导入的工厂模式不允许构造对象的新实例以进行组合
- vue.js - 在 vuejs 中使用 axios 方法处理错误
- arrays - 反应我如何多映射值以提高效率
- google-cloud-platform - Terraform - 创建 Google Cloud SQL 实例不起作用
- python - Python 3.7.0 - 结构 calcsize、错误或功能?
- android - 如何在同一时间线android中播放多个视频?
- html - 我们可以从 Angular 应用程序中排除 tsconfig.spec.json
- javascript - 如何使用“-”将日期作为数字转换为日期
- java - 如何扩展 Collectors 类