When I wrote a webpage in HTML, <LINK rel = "stylesheet" type = "text/CSS" href = "CSS/css.css"/> link an external CSS style sheet to a webpage. Other images include background-color. padding, margin, and so on can work normally, but it means that the background-image does not work, and sometimes the background-image: URL ("" absolute path "") is in the air; it can be displayed, but we do not advocate the writing of this absolute path. What is the reason for this phenomenon?
Note ::Background-image: URL written in the CSS style sheet (the path of the image is relative to the path of the current CSS file, rather than the path of the webpage that we usually consider to be relatively added to the CSS style);
For example, the current directory contains the index.html and CSS folders (including: css.css) and the imagesfolder (crouton containing top.jpg)
Incorrect description and Syntax: Background-image: URL ("images/top.jpg"); -------------------------------------> the incorrect description of the image should be based on the index.html webpage.
Correct thinking and writing:Background-image: URL ("../images/top.jpg ");-----------------------------------> The image must be written in the path of the relative css.css file.
Where../Indicates the upper-level directoryDo not write it as./. This indicates the current directory.
When I wrote a webpage in HTML, <LINK rel = "stylesheet" type = "text/CSS" href = "CSS/css.css"/> link an external CSS style sheet to a webpage. Other images include background-color. padding, margin, and so on can work normally, but it means that the background-image does not work, and sometimes the background-image: URL ("" absolute path "") is in the air; it can be displayed, but we do not advocate the writing of this absolute path. What is the reason for this phenomenon?
Note ::Background-image: URL written in the CSS style sheet (the path of the image is relative to the path of the current CSS file, rather than the path of the webpage that we usually consider to be relatively added to the CSS style);
For example, the current directory contains the index.html and CSS folders (including: css.css) and the imagesfolder (crouton containing top.jpg)
Incorrect description and Syntax: Background-image: URL ("images/top.jpg"); -------------------------------------> the incorrect description of the image should be based on the index.html webpage.
Correct thinking and writing:Background-image: URL ("../images/top.jpg ");-----------------------------------> The image must be written in the path of the relative css.css file.
Where../Indicates the upper-level directoryDo not write it as./. This indicates the current directory.