简体   繁体   English

背景图片未显示

[英]background image not displaying

can someone please tell me why the background image is not displaying in my php code. 有人可以告诉我为什么背景图片未显示在我的PHP代码中。

#wrap-iframe{
    background-image: url(bg_01.gif); 
    background-repeat: no-repeat;   
    border:0 none;
    min-width:760px;
    min-height: 700px;
}

this is the CSS i have. 这是我拥有的CSS。 the div box is displayed flawlessly. div框完美显示。 the image url is correct. 图片网址正确。 if i inlcude the image through the tag, it shows up. 如果我通过标签包含图像,则会显示出来。

i was not this bad at CSS...:-( 我在CSS上还不错... :-(

Note that the image path must be relative to the stylesheet. 请注意,图像路径必须相对于样式表。 If your stylesheet is in a different directory than the page, you must adjust the path in url() accordingly. 如果样式表与页面位于不同的目录中,则必须相应地调整url()的路径。

You can right click the DIV in Firefox and click "show background image". 您可以在Firefox中右键单击DIV,然后单击“显示背景图像”。 It will take you to the URL where firefox is looking for the image, and you can see whether it's correct or not. 它将带您到firefox在其中查找图像的URL,然后可以查看它是否正确。

I recommend using an "absolute" path. 我建议使用“绝对”路径。 Start with a forward slash and describe the path from the HTML root forwards, ie /images/bg_01.gif would resolve to http://yourdomain.com/images/bg_01.gif 以正斜杠开头,并描述从HTML根开始的路径,即/images/bg_01.gif将解析为http://yourdomain.com/images/bg_01.gif

I always put quotes round the filename too, though they may not be 100% necessary: 我也总是将引号也放在文件名的周围,尽管它们可能不是100%必需的:

background-image: url("/images/bg_01.gif"); 

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

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