How to write absolute path in css: first check the local project directory; then import the image and enter the absolute path such as "background: url(E:/py_web/python/module/static/img/bg.png) ;" That's it.
The operating environment of this tutorial: Windows 7 system, css3 version. This method is suitable for all brands of computers.
Recommendation: "css video tutorial"
Writing absolute path in css
Writing absolute path in css needs to start from the drive letter , fill in the directory names one by one until the required files are found.
For example, a project directory is as follows:
If you want to introduce a certain image in css, you can write like this
background: url(E:/py_web/python/module/static/img/bg.png);
Note: /static/img /bg.png is also a relative path, which is relative to the root directory. If you want to use this path, you must first figure out what the root directory is. If your web framework can set the route to the root directory of the website's static files, such as setting it to a static folder, then the css path can be written as img/bg.png. If there is no setting, the root path generally corresponds to the root directory of the hard disk.
The above is the detailed content of How to write absolute path in css. For more information, please follow other related articles on the PHP Chinese website!