在你问之前,是的,我把我想要设置的图像作为背景放在与CSS文档相同的文件夹中.
这是HTML:
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="C:/Users/16jlavarnway/Desktop/blah/JacobLFinalCSS.css"/>
<title>Programming with Python</title>
</head>
<body>
<br>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是CSS
body {
background-image:url:("C:/Users/16jlavarnway/Desktop/blah/Background2.png") fixed center;
}
Run Code Online (Sandbox Code Playgroud)
这应该是正确的语法
body {
background-image:url("C:/Users/16jlavarnway/Desktop/blah/Background2.png") fixed center;
}
Run Code Online (Sandbox Code Playgroud)
此外,如果您的网站在线托管,您的图像路线应该是
body {
background-image:url("Background2.png") fixed center;
}
Run Code Online (Sandbox Code Playgroud)
与HTML相同,您将不得不更改路线.