Div背景未设置

时间:2012-04-23 20:57:05

标签: css html

#contentwrapper {
   background: #111;
   background: url('~/img/bg-black.png');
   width: 100%;
}
#content {
   width: 340px;
   height: 165px;
   margin: 240px auto;
   text-align: center;
}

这是HTML:

<div id="content-wrapper">
<div id="content">
<h1 style="text-align: center">Test</h1>
<div style="clear:both"></div>
</div>
</div>

我的问题是我试图将contentwrapper的背景图像设置为给定的链接,但是当我运行它时,它不会显示。我尝试过重写,重新加载,读取等等。什么都不行

有什么想法吗?

2 个答案:

答案 0 :(得分:5)

拼写错误
id contentwrapper

<div id="content-wrapper">

答案 1 :(得分:1)

尝试删除波浪号(~)字符,并从站点的根目录中映射它。您也可以尝试删除引号或使用双引号,但它应该以两种方式工作:

background: url(/images/dialog-gradient-beige.png);

如果您无法从网站的根目录进行映射,请尝试退回到images目录:

background: url("../images/bg-black.png");