html - 是否可以全屏覆盖来自 api 的图像?
问题描述
我正在尝试将来自Unsplash Source API的图像居中并覆盖整个屏幕。
我认为,因为在已经应用 css 之后图像实际上会被获取,所以它不能像这样工作:
(如果演示可能会被掩盖,请全屏运行)
html, body {
margin: 0px;
width: 100%;
height: 100%;
}
.centered-image {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
width: 100%;
height: 100%;
background: url(https://source.unsplash.com/collection/1228371) no-repeat center center fixed;
}
<div class="centered-image"></div>
你们知道变通方法吗?
解决方案
.centered-image {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-position: center;
width: 100%;
background-repeat: no-repeat;
height: 100%;
background-image: url(https://source.unsplash.com/collection/1228371);
}
做了一些 CSS 更改。试试这个。
推荐阅读
- postgresql - 获取索引列总大小
- python - 如何使用特定的标准偏差 python 列表理解对列表中的值进行分组
- linux - Bash:重定向来自 2 个来源的输入?
- python - Python Dash在过滤时隐藏html表格
- amazon-web-services - 开发 REST API 时处理“AWS 堆栈资源限制”的正确方法是什么?
- android - 是否可以检测三连击?
- parallel-processing - 有一组复数,如何在Fortran中做并行数值积分?
- c# - 如何从用户给出的列表中获取 n 个随机名称?
- javascript - 所见即所得的summernote html编辑器获取按键/更改/输入事件
- javascript - 数组变量中的预期标识符