我尝试了不同的选项,也尝试了 stackoverflow 上发布的选项。但似乎没有任何效果。我在/public/images 中有一个 logo.png 文件,在样式表中有一个 custom.css 文件。
我希望每个页面的背景都是logo.png(全屏)
经过大量搜索后,我尝试了以下方法。但我一无所获。背景是空白的。
请帮忙
body{
background: url('../images/logo.png') repeat-x ;
text-align:center;
color:#fff;
}
最佳答案
你绝对不想使用 repeat-x 为了说明原因,请使用以下链接 http://www.w3schools.com/css/tryit.asp?filename=trycss_background-image并粘贴下面的代码,看看会发生什么,然后删除 repeat-x 并查看结果
<html>
<head>
<style type="text/css">
body {
color: white;
background:url('paper.gif') repeat-x;
}
</style>
</head>
<body>
<h1>Hellos World!</h1>
</body>
</html>
如果您的图像在删除 repeat-x 后没有显示,很可能是路径问题(正如其他人已经指出的)或图像不正确。
唯一的另一件事是,如果您的 css 中定义了其他类/div,它们会覆盖您在正文中设置的背景属性。其他人建议您使用 Firebug 。我必须全心全意地同意。在处理 HTML 和 CSS 问题时,Firebug 非常重要。
Firebug 可用于 Chrome 和 Firefox 浏览器(Firefox 作为插件,默认为 Chrome),但我不确定其他浏览器是否可用。
关于html - 返回 : Full Screen Background Image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6895190/