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
The question arises This question arose when I wa...
1. Virtual Machine Preparation 1. Create a new vi...
If you forget your MySQL login password, the solu...
Preface Let’s take a look at the final effect fir...
template <el-table :data="dataList"&...
This article example shares the specific code of ...
Table of contents 1. Parent-child component commu...
Preface Linux does not have a prominent Recycle B...
Format Encoding 1. Please set the page width with...
MySQL backup Cold backup:停止服務進行備份,即停止數據庫的寫入Hot ba...
KVM stands for Kernel-based Virtual Machine, whic...
Table of contents Class component event binding F...
Table of contents Vue3 + TypeScript Learning 1. E...
For example, to query yesterday's newly regis...
This article shares the specific code of Vue+expr...