为什么当我在本地桌面上启动文件时没有显示 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;
}
我保证接受对我最有帮助的答案,所以请为我调试代码。感谢您的帮助!
最佳答案
有一些语法错误:
- 把链接放在引号里
- 去掉url和( 之间的空格
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;
}
<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>
关于html - 为什么 css 背景图片不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40122324/