18910140161

HTML-不会加载CSS背景图像,也不会更新代码-堆栈溢出

顺晟科技

2022-10-18 12:49:57

178

在我的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

中的点的数量

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

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


顺晟科技:

background更改为background: url('../img/homeTrans2.svg') no-repeat top right/ cover;或使用双引号。某些浏览器可能无法正确获取相对URL.

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

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航