我需要创建一个可以在单个文件中打开和运行的小型网站。我不太清楚如何显示图像背景。我的图像在 Desktop/assignment/Website-Background.jpg
中。我已经尝试了很多不同的方法来让它工作,但它就是不会。我当前的代码是:
body{
height: 100%;
}
.bg {
background-image: url("Website-Background.jpg");
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
我试过也试过
body {
background-image: url("Website-Background.jpg");
}
谁能指出我做错了什么?
最佳答案
首先在你的浏览器中按 F12,你会在控制台窗口中看到图像是否被调用,然后如果它被调用并且没有错误那么也许设置 200px 的高度并查看图像是否显示.
关于html - 背景问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44525435/