为什么我的背景图片不会,特别是我认为文件路径可能是问题?

问题描述 投票:0回答:1

我想在标题后面添加背景图像,但是当我运行代码时,图像甚至没有加载。

h1{
    color: khaki;
    font-size: 100px;
    font-weight: bold;
    text-align: center;
    background-image: url(resources/pattern.jpeg);
    background-size: cover;
    background-position: center;
}

当我点击文件路径(我直接从 VS Code 给出的文件路径复制)时,它告诉我“加载图像时发生错误”。 我还尝试编写整个文件路径:C:\HTMLProjects\DevProject 资源\pattern.jpeg

我的文件排序如下: (https://i.stack.imgur.com/Nn99W.png)

html css background-image
1个回答
0
投票

你能展示一下你的html吗? 您可能忘记将 css 文件添加到 html 中?

© www.soinside.com 2019 - 2024. All rights reserved.