我需要的图像文件路径是 xampp1/htdocs/projecto/images/bgs.jpg 我的 css 文件路径是 xampp1/htdocs/projecto/css/sp.css 我的 CSS 代码是:
body
{ margin-top:100px;
background-color:linen;
background-image:url("/projecto/images/bgs.jpg");
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
这就是我在我的 html 文件中链接它的方式:
<head>
<link rel="stylesheet" type="text/css" href="/projecto/css/sp.css">
但是我的背景图片没有显示...
最佳答案
尝试使用 ../从 css 文件夹向上一级,而不是直接引用元素文件夹。试试下面的代码,看看是否有帮助
background-image:url("../images/bgs.jpg");
关于html - 将已更改文件夹中的背景图像插入到 css 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42732668/