首页 > 解决方案 > CSS背景图像不会被加载并且代码不会被更新

问题描述

在我的 CSS 文件中,我编写了代码

/*The code I write*/
.wrapper::before {
    content: "";
    position: absolute;
    bottom: -30%;
    left: 0;
    height: 100%;
    width: 100%;
    background: url(../img/homeTrans2.svg) no-repeat top right/ cover;
}

注意:我确保保存我的工作

但是当我尝试加载它时,我的计算机将代码读取为

/*The code when the computer reads it*/
.wrapper::before {
    content: "";
    position: absolute;
    bottom: -30%;
    left: 0;
    height: 100%;
    width: 100%;
    background: url(./img/homeTrans2.svg) no-repeat top right/ cover;
}

注意:注意后台 URL 中的点数

为什么我无法访问我的文件?

注意:我知道我可以重新组织我的文件以使其正常工作,但我希望我的文件夹更有条理

标签: htmlcss

解决方案


尝试将图像保存在项目的同一目录中,然后更改路径。


推荐阅读