背景不工作的一个div因为它应该 [英] Background not working for a div as it should

查看:152
本文介绍了背景不工作的一个div因为它应该的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个路径一个奇怪的问题,这一个工程(在Windows上):

I have a strange problem with paths, this one works (on Windows):

<div style="background:url('folder1/image.gif')...

但是这一次是不行的(无图像显示出来):

But this one won't work (no image shows up):

<div style="background:url('/folder1/image.gif')...

不过这个页面说完全相反(不是第一,但第二个版本应该工作)的背景不工作的一个div

任何人知道是什么原因可能是什么?

Anybody knowing what the reason might be?

推荐答案

你的HTML被用于渲染页面什么的第一个URL相对于服务器的文件夹。

The first url is relative to the folder in server what your HTML is used to render the page.

例如,如果你得到:

www.mywebsite.com/index.html

它会考虑:(例如2)

www.mywebsite.com/folder1/image.gif

但如果你是在其他文件夹,如:

but if you are in another folder like:

www.mywebsite.com/subfolder/index.html

它看起来在:

www.mywebsite.com/subfolder/folder1/image.gif

如果您在beggin使用'/',是相对路径不多,它看起来总是在根网站,就像为例2无论在哪里你的HTML的位置。

If you use a '/' in the beggin, the path isn't more relative, it always look in the root website, like exemple 2 no matter where your html is located.

这篇关于背景不工作的一个div因为它应该的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆