Home > Web Front-end > JS Tutorial > body text

How to solve the problem of background image not loading

一个新手
Release: 2017-09-19 10:26:45
Original
3976 people have browsed it

When I used to write web pages in HTML, I linked external css style sheets to the web page. Others like: background-color, padding, margin, etc. all worked normally, but background-image did not work, and Sometimes background-image:url(""absolute path""); can be displayed in a fit of anger, but we strongly discourage this way of writing absolute paths, so what is the reason for this phenomenon?
**

Note: The background-image:url written in the css style sheet (the path of the image is relative to the path of this css file, not the relative adding css style that we usually think of The path of the web page);

**
For example: In the current directory, there are index.html and css folders (which contain: css.css) and images folders (which contain top .jpg)
Wrong thinking and writing: background-image:url("images/top.jpg"); ———————————–>>Error I think the path of the image should be for the index.html web page.
Correct thinking and writing method: background-image:url(“../images/top.jpg”);————————————>Path of the image What should be written is the path relative to the css.css file
where ../ represents the upper-level directory, do not write ./ which represents the current directory.
This problem has troubled me for a long time. I will summarize it today and remind myself! ! I hope those who haven’t figured it out yet will understand!

The above is the detailed content of How to solve the problem of background image not loading. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template