【发布时间】:2013-07-02 08:11:26
【问题描述】:
我有一个标题,我正在尝试通过图像文件对其应用背景纹理。 html、css 和图像文件都在同一个目录中。这是html:
<body>
<div id=header>
<div id=picture>
<img=src=picture.jpeg alt="Profile" align="right" width="180" height="180"/>
</div>
<div id=caption>
<h1>BannerText</h1>
</div>
</div>
</body>
这是外部样式表代码:
#header
{
background= url('texture.png');
width:98%;
}
纹理图像未出现。如果我用原来body标签的background属性,也就是
<body background="texture.png">
确实有效。这告诉我这不是 url 的问题,并且所有三个文件都在同一个文件夹中,因此 html 和 css 文件中的相对路径是相同的。为什么纹理图像不显示为标题 div 的背景?
【问题讨论】:
-
首先,虽然这可能是一个错字,但在您的顶部应该是
<img src="picture.jpeg" alt..... -
外部工作表是否与您的页面在同一目录中?文件
texture.png将从您的样式表所在的任何目录中提取,因为您没有指定目录 - 也是 fakeheal 所说的。
标签: html css image background