简体   繁体   English

CSS + IE 6 =背景图片未显示(并拔出头发)

[英]CSS + IE 6 = Background-Image is not showing (and pulling hair out)

I have a web page. 我有一个网页。 This web page looks correct in IE 7, 8 FF 2, 3, 3.5 Safari 3, 4 Opera 9, 10 and Chrome. 在IE 7、8 FF 2、3、3.5 Safari 3、4 Opera 9、10和Chrome中,此网页看起来正确。 Essentially everything except IE 6. 基本上是除IE 6以外的所有内容。

The layout even looks fine. 布局看起来还不错。 The only thing that is not working as expected is that none of the background-images are showing properly. 唯一无法正常工作的是没有任何背景图像正确显示。 Here is the code that I am trying to apply a background image to: 这是我尝试将背景图片应用于的代码:

<div id="theDiv" style="height:29px; width: 100%; background-image: url('/../../Images/divBG.jpg');position:absolute; top:10px;">
  <ul style="list-style-type:none; position:relative; display:inline;">
    <li style="position:relative; display:inline;">Item 1</li>
    <li style="position:relative; display:inline;">Item 2</li>
  </ul>
</div>

My directory structure looks like this 我的目录结构如下所示

root
-- index.html
-- Images
-- -- Application
-- -- -- divBG.jpg
-- Styles
-- -- Application
-- -- -- mystyle.css

Please note that the CSS information I provided is actually in mystyle.css. 请注意,我提供的CSS信息实际上在mystyle.css中。 However, in an effort to "debug" this, I moved the css code inline with the HTML code. 但是,为了对此进行“调试”,我将css代码与HTML代码内联了。 What am I doing wrong? 我究竟做错了什么?

Thank you What am I doing wrong? 谢谢我做错了什么? This is driving me nuts! 这真让我发疯!

Take out the quotes in the url('...') part. 取出url('...')部分中的引号。 Those aren't necessary and might be causing issues. 这些不是必需的,可能会引起问题。 Also, the URL should be url(Images/Application/divBG.jpg) , not url(/../../Images/divBG.jpg) , at least if you're doing the CSS inline in the index.html file. 另外,URL应该是url(Images/Application/divBG.jpg) ,而不是url(/../../Images/divBG.jpg) ,至少是在index.html文件中内联CSS的情况下。 If you're doing the CSS in the css file, it would need to be url(../../Images/Application/divBG.jpg') (note, NO beginning slash). 如果您要在css文件中创建CSS,则该文件必须为url(../../Images/Application/divBG.jpg') (请注意, url(../../Images/Application/divBG.jpg')斜杠开头)。

'/../../Images/divBG.jpg' does not contain Application folder '/../../Images/divBG.jpg'不包含应用程序文件夹

perhaps ./Images/Application/divBG.jpg 也许./Images/Application/divBG.jpg

尝试这个:

'../../Images/divBG.jpg'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM