html - 返回 : Full Screen Background Image

标签 html css background-image

我尝试了不同的选项,也尝试了 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/

相关文章:

javascript - Bootstrap Navbar Logo 和 Menu CSS 类在滚动后发生变化

css - 如何确保用户看到新标识?

jquery - 每个 session 只有一次模态弹出

android - 如何阻止 "Go"按钮被替换为 "Next"- Chrome Android 浏览器应用程序

java - 将 li 列表从客户端传递到 Spring MVC Controller

javascript - 从 JavaScript 加载的树中的自定义样式 Kendo Treeview 节点文本

javascript - 在javascript中选择两个没有id的iframe之一

css - 使用 CSS 样式表(背景图像属性)在同一行 float 2 个图像

html - 背景用 html 重复,正文高度为 100%,用 css 粘性页脚

html - 如何使位置 :absolute divs follow the paddings of a position:relative parent;