为什么我在本地桌面上启动文件时没有显示CSS背景图像?这是我的代码:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" text="type/css" href="discovery.css">
<title>Programming Club Official Blog</title>
</head>
<body>
<h1>Programming Club Official Blog</h1>
<p>This is a blog that allows member of the programming club to keep in
touch about what we are doing in the club. Feel free to look at the code by pressing Ctrl-U! ~ Nathan Tran</p>
</body>
</html>
我的CSS代码:
html {
background:url (http://smashingyolo.com/wp-content/uploads/2014/05/Best-
Website-Background-Images10.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
我保证接受最能帮助我的答案,请为我调试代码。谢谢你的帮助!
答案 0 :(得分:1)
有一些语法错误:
html {
background:url("http://smashingyolo.com/wp-content/uploads/2014/05/Best-Website-Background-Images10.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
&#13;
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" text="type/css" href="discovery.css">
<title>Programming Club Official Blog</title>
</head>
<body>
<h1>Programming Club Official Blog</h1>
<p>This is a blog that allows member of the programming club to keep in
touch about what we are doing in the club. Feel free to look at the code by pressing Ctrl-U! ~ Nathan Tran</p>
</body>
</html>
&#13;
答案 1 :(得分:0)
不需要在引号下添加图片网址。
问题是错误的网址。图像URL中有空格。删除之间的空间 最佳和网站
http://smashingyolo.com/wp-content/uploads/2014/05/Best-%20Website-Background-Images10.jpg
html {
background:url(http://smashingyolo.com/wp-content/uploads/2014/05/Best-Website-Background-Images10.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
&#13;
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" text="type/css" href="discovery.css">
<title>Programming Club Official Blog</title>
</head>
<body>
<h1>Programming Club Official Blog</h1>
<p>This is a blog that allows member of the programming club to keep in
touch about what we are doing in the club. Feel free to look at the code by pressing Ctrl-U! ~ Nathan Tran</p>
</body>
</html>
&#13;