0

我将我的样式表链接到我的基本 html 文件。

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

当我单击转到链接时,它会转到正确的文件。我可以更改背景颜色和所有其他边距。但是当我插入一个 url 时,css 似乎找到了图片,但没有加载到 html,如果我单击预览,则没有加载图像。

 picture {
 width: 984px;
 height: 148px;
 background-image:url(img/header.jpg/);
4

5 回答 5

0

在标题标签而不是标题标签下链接您的 CSS,因为标题标签是指网站标题。

<header>
    <title></title>
    <link rel="stylesheet" type="text/css" href="style.css">
</header>

以及评论中提到的错字,并确保您的目的地是正确的。]

p/s(错字)

picture{
    background-image:url(img/header.jpg);
}
于 2013-09-03T07:29:22.773 回答
0

就像下面的代码paste在你的html

HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>TEST</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="etbplaza.nl/css/style_basic.css"; />
</head>
<body>
<div class="picture"> your code hre </div>
</body>
</html>

CSS

.picture {
 width: 984px;
 height: 148px;
 background-image:url(img/header.jpg/);
于 2013-09-03T07:31:37.593 回答
0

这可能是一个错字:

picture {
 width: 984px;
 height: 148px;
 background-image:url(img/header.jpg/);

图片没有可能导致问题和/或可能尝试url('img/header.jpg');在引号内使用的类或 id 选择器。或者url('../img/header.jpg')但我们不知道图像的位置。

也试试这个:

  1. 检查元素
  2. 将鼠标悬停在路径上,看看是否正在加载路径,如果是,您的图像会显示在那里

看到这个技术

于 2013-09-03T07:37:40.927 回答
0

更改background-image:url(img/header.jpg/);background-image:url(img/header.jpg); 确保/path/to/file正确,如果图片是 div 类,那么它将像.picture在您的 CSS中一样

于 2013-09-03T07:51:33.557 回答
0
you have to use the css as in the form of class or id and try the code as

.picture {
 width: 984px;
 height: 148px;
 background-image:url(img/header.jpg);
}

or as id 

#picture {
 width: 984px;
 height: 148px;
 background-image:url(img/header.jpg);
}

surly you got the preview of the Image to your HTML page. 
Please check the path of css file is correct or not.
于 2013-09-03T08:58:04.377 回答