我正在尝试使用background-image设置背景图片:url但它无效。
<!doctype html>
<html>
<head>
<title>MyTitle</title>
<style type="text/css">
body{
<!-- background-color:green; -->
background-image:url("background.jpg");
<!-- color:white; -->
}
</style>
</head>
<body>
</body>
</html>
请帮助!!
答案 0 :(得分:6)
<!-- comment -->
是CSS块中无效的注释语法。这可能会破坏你的CSS规则。
尝试
/* comment */
答案 1 :(得分:3)
标签不会嵌套到标签中。
尝试
<!doctype html>
<html>
<style type="text/css">
body{
/* background-color:green; */
background-image:url("background.jpg");
/* color:white; */
}
</style>
<head>
<title>MyTitle</title>
</head>
<body>
</body>
</html>
CSS中的注释定义为......
/*this is a comment*/