CSS图像在另一个文件夹中 [英] CSS Images In another Folder
本文介绍了CSS图像在另一个文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将图片添加到名为images的文件夹中,并将CSS添加到名为css的文件夹,现在我想使用images文件夹中的图片。我如何做到这一点?当我使用这个,他们没有出现:
I added the images into the folder called "images" and CSS to folder called "css", now I want to use the images in "images" folder. How do I do this? When I used this, they didn't show up:
background: url('/images/bg.jpg');
我也尝试过这些:
background: url('../images/bg.jpg');
background: url('../../images/bg.jpg');
我应该使用哪个路径来存取我的图片?
What is the path I should be using to access my images?
推荐答案
如果您有如下的文件夹结构:
If you have a folder structure like follows:
/public_html/
/css/
/images/
/index.html
$ b
Then your CSS should work.
- 从/开始返回根目录,
开始于
- 从../../开始向后移动一个目录并开始
目录向后并从那里开始(依此类推...)要向前移动,只需从第一个
子目录开始,并继续前进
- Starting with "/" returns to the root directory and starts there
- Starting with "../" moves one directory backwards and starts there
- Starting with "../../" moves two directories backwards and starts there (and so on...) To move forward, just start with the first
subdirectory and keep moving forward
点击此处阅读更多: http:// css-tricks.com/quick-reminder-about-file-paths/
这篇关于CSS图像在另一个文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文