body {
background-image: url('./images/bg.jpg')
}
其中 ./images/bg.jpg 是图片的本地文件路径,可以根据实际情况替换为其他路径。
请注意,如果您的 CSS 文件和图像文件不在同一目录中,则需要使用绝对路径或相对路径来指定图像文件的位置。
写css背景图片代码可以参考以下:
<html>
<head>
<styletype="text/css">
body{background-image:url(abc.jpg)}
</style>
</head>
<body>
</body>
</html>
扩展资料:
1、背景图片语法:{background-image:url(url)|none}
2、背景固定语法:{background-attachment:fixed|scroll}
3、背景重复语法:{background-repeat:inherit|no-repeat|repeat|repeat-x|repeat-y}
4、背景定位语法:{background-position:数值|top|bottom|left|right|center}
参考资料来源:百度百科-CSS语法