简体   繁体   English

背景图片未显示CSS

[英]Background image not showing CSS

I would like to have a background-image on my website. 我想在我的网站上有一张背景图片。 For some reason when I use a placeholder ( background: url(http://via.placeholder.com/1920x500) no-repeat center top;) , the placeholder appears with no issues, but when I use the image sitting on my laptop... It does not show. 由于某种原因,当我使用占位符( background: url(http://via.placeholder.com/1920x500) no-repeat center top;) ,占位符没有出现问题,但是当我使用坐在笔记本电脑上的图像时...它不显示。 Below is how I display the image: 以下是我显示图像的方式:

background: url("/images/about.jpeg") no-repeat center top;

I also tried: 我也尝试过:

background-image: url("/images/about.jpeg") no-repeat center top;

and I get the same result. 和我得到相同的结果。 Please assist the new guy to CSS 请协助新手使用CSS

Below is the file structure: 下面是文件结构:

在此处输入图片说明

If your stylesheet is inside the CSS folder, the CSS rule should be like this: 如果样式表位于CSS文件夹中,则CSS规则应如下所示:

background: url("../images/about.jpeg") no-repeat center top;

ie, go out of the "css" folder and into the "images" folder 即, “ css”文件夹转到 “ images”文件夹

css file is unable to locate your image. css文件无法找到您的图像。

you have to change your image url to 您必须将图片网址更改为

url("../image_url")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM