In CSS files, sometimes you need to use background, that is, add a background image, which is generally used when making button styles. Adding background images in CSS can be divided into the following types according to the relative position of the image and the CSS file: 1. In the same package: background: url(aaa.gif); 2. Different packages: In this case, there are two ways to set it. One is to use an absolute path, that is, upload/2022/web/www.iteye.com, but it is generally not recommended and is not conducive to project migration; the other is to use a relative path. First, you need to find a root directory common to the image file and the css file, and then add the subdirectory of the image, for example: CSS file location: WebRoot/test/css/a.css Image file location: WebRoot/platform/resource/images/icons/a.gif If you want to find the common root directory, you need to use "../". This path means the parent directory. If there are two parent directories, it is "../../". Then, according to this writing method, the background image css in a.css should be written like this: Copy code The code is as follows:background:url(../../platform/resource/images/icons/a.gif) Why? First, we observe the location of these two files and find that the common root directory is WebRoot. We first find the WebRoot at the location of a.css, so we have "../../" and then the path of the subdirectory of the spliced image is "platform/resource/images/icons/a.gif". Putting them together is the result above. |
<<: Detailed explanation of HTML style tags and related CSS references
>>: Detailed explanation of common template commands in docker-compose.yml files
This seems to be no longer possible with the new ...
I recently read about vue. I found a single-file ...
Installation of MySQL decompression version and N...
JavaScript can do a lot of great things. This art...
Table of contents Overview Static type checking C...
Table of contents Preface Single file components ...
There are two types of web page box models: 1: Sta...
MySQL 8 official version 8.0.11 has been released...
HTML forms are used to collect different types of...
Question: In index.html, iframe introduces son.htm...
1. Preparation Install Tomcat on Linux system, us...
NC's full name is Netcat (Network Knife), and...
By default, the width and height of the header ar...
Table of contents 1. Through HBuilderX visual int...
The article mainly records the simple installatio...