html - 背景图像未显示在html页面中
问题描述
我是 html 的初学者,我正在尝试使用图像作为我页面的完整背景。我希望图像适合我的场景,这样我就不必向下滚动来查看图像的其余部分。我已经尝试过了,但图像甚至没有以 .
.html , .body{
margin:0;
height:100%;
}
#map{
background: url("HTML_FILES/IMAGES/map.jpg");
height:100%;
width:100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
<div id = "map"></div>
我的文件夹结构如下:
PROJECT
HTML_FILES
mypage.html
IMAGES
map.jpg
感谢您帮助指导我加载图像并正确调整它。先感谢您 。
解决方案
使用下面的样式来完成它。
body {
background: url(HTML_FILES/IMAGES/map.jpg);
height: 100%;
width: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
推荐阅读
- r - 转向具有重复列名的宽数据框
- python - 当缺少值但散点图工作正常时,pandas DataFrame 线图不起作用
- ecmascript-next - 空值合并后缀运算符?
- python - 关于从维基百科抓取子弹信息的问题
- sql - 如何从一列中计算过去 X 周数据的百分比?
- javascript - 如何正确映射 url 数组并使数据进入状态?
- mongodb - 为什么 Mongodb 创建一个带有 ObjectsId 的数组而不是一个简单的对象数组?
- python - 无法为 api 请求设置参数
- wagtail - 覆盖 Wagtail Page.get_url()?
- c++ - 访问/读取值时浮动损坏(Cout 打印)