如何使用css样式标记更改html背景图像?

如何使用css样式标记更改html背景图像?,css,Css,我一直在尝试使用css为我的html页面设置一个背景图像,但我在这样做时遇到了一些问题。当我在下面使用这个代码时,它工作了 <style> html {background-image: url("D:/HtML5/astronomytweak/img/andromeda.jpg");} </style> html{background image:url(“D:/HtML5/astronomytlew/img/andromeda.jpg”);} 但是,当我尝试使

我一直在尝试使用css为我的html页面设置一个背景图像,但我在这样做时遇到了一些问题。当我在下面使用这个代码时,它工作了

<style>
html  {background-image: url("D:/HtML5/astronomytweak/img/andromeda.jpg");}
</style>

html{background image:url(“D:/HtML5/astronomytlew/img/andromeda.jpg”);}
但是,当我尝试使用这个,我想上传到在线服务器,它是不工作的。下面是一个我正在尝试使用,但不起作用的


html{背景图像:url(“img/andromeda.jpg”);}


请告诉我这个挑战需要帮助。提前谢谢。

尝试将html更改为正文

<style>
  body  {background-image: url("D:/HtML5/astronomytweak/img/andromeda.jpg");}
</style>

body{background image:url(“D:/HtML5/astronomytlawe/img/andromeda.jpg”);}
尝试设置相对路径(./)


html{背景图像:url(“./img/andromeda.jpg”);}

因为我正试图将其上传到在线服务器上,所以我希望url是这样的(“img/andromeda.jpg”)。这可能吗?图像使用的路径将与html文件相对。您的
html/css
文件是否与
img/adromeda.jpg
位于同一目录下?您可能在
url(“…”)
<style>
html  {background-image: url("./img/andromeda.jpg");}
</style>