背景: url('example.jpg'); 不工作!

Cai*_*ene 4 html css

好的,这是我的文件结构:

+WWW

  • 索引.html
  • 样式文件
  • 地图.jpg

CSS:

body {
    background: #000 url('map.jpg') repeat/repeat-x/repeat-y/no-repeat scroll/fixed top/center/bottom/x-%/x-pos left/center/right/y-%/y-pos;
}
Run Code Online (Sandbox Code Playgroud)

HTML:

<html>
<head>
    <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

问题:map.jpg 无法在任何浏览器(Firefox、Safari)或 TextMate 预览中显示!

Nic*_*ver 5

你在这里有两个问题,首先是你的 CSS 被关闭,它不应该有每个参数的选项清单:

body {
  background: #000 url('map.jpg');
}
Run Code Online (Sandbox Code Playgroud)

那么<body>没有任何内容,所以它没有尺寸,你需要在那里放一些东西来查看是否有任何图像,否则<body>元素的高度将非常小,如果不是 0,取决于浏览器。