css - 如何使用 css 样式标签更改 html 背景图像?
问题描述
我一直在尝试使用 css 为我的 html 页面设置背景图像,但我遇到了一些问题。当我在下面使用此代码时,它虽然有效
<style>
html {background-image: url("D:/HtML5/astronomytweak/img/andromeda.jpg");}
</style>
但是当我尝试使用我想上传到在线服务器的这个时,它不起作用。下面是我正在尝试使用但无法正常工作的那个。
<style>
html {background-image: url("img/andromeda.jpg");}
</style>
我需要帮助来应对这个挑战。先感谢您。
解决方案
尝试设置相对路径(./)
<style>
html {background-image: url("./img/andromeda.jpg");}
</style>
推荐阅读
- omnet++ - 构建 INET、Veins、Veins_inet3、SimuLTE 以集成到我的模拟时出错
- python - 使用python将文件上传到s3存储桶时权限被拒绝
- python - 如何使用 ax.get_subplotspec().is_first_col() 而不是 is_first_col
- java - 如何更改 javafx 警告框的图标
- installation - ROS Noetic 环境设置(目录未找到)
- c# - 在转换为枚举的对象上调用重载函数
- c++ - 如何获取键盘名称?(在视觉上区分特定语言的键盘)
- pandas - 我怎样才能像这样组合列和行
- css - 谁能帮我解决这个设计问题?
- google-sheets - 谷歌表格:计算具有多个答案的表单数据。arraformula,拆分和转置