CSS css背景图片不会显示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26207647/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:38:12  来源:igfitidea点击:

css background image won't display

cssimagebackground-image

提问by BonfireConspiracy

I have tried everything! But my background image (gif) won't show up..

我什么都试过了!但我的背景图片 (gif) 不会出现..

My files are stored in my public_html on ftp.

我的文件存储在 ftp 上的 public_html 中。

I have my file linked like this in my html doc:

我在我的 html 文档中像这样链接了我的文件:

<link href="css/arena.css" rel="stylesheet" type="text/css" />

And I have the following lines in css:

我在 css 中有以下几行:

body {
background-image: url('../images/2.gif'); 
}

I hope someone can help me out because this is really frustrating.

我希望有人可以帮助我,因为这真的很令人沮丧。

Thanks in advance.

提前致谢。

采纳答案by Ahmad

There is an error in your syntax, you have to remove :.

您的语法有错误,您必须删除:.

url('../images/2.gif)instead of url:('../images/2.gif')

url('../images/2.gif)代替 url:('../images/2.gif')

You could check background-image property documentation.

您可以查看background-image 属性文档

回答by BonfireConspiracy

Problem is solved. It had to do with the permissions. Thanks y'all for helping out, greatly appreciated!

问题解决了。它与权限有关。谢谢大家帮忙,不胜感激!

回答by Mac Hooper

Changing the path to include ../img/bgheader.jpg fixed it.

更改路径以包含 ../img/bgheader.jpg 修复了它。