我目前正在用PHP建立一个网站。开发它时,我使用xampp(localhost),并且图片可见。
<div data-bs-parallax-bg="true" style="height:500px;background-image:url("assets/img/mypicture.jpg");background-position:center;background-size:cover;">
当我想上传到Web服务器时,图片是不可见的。
我尝试了这些选项,但仍然无法正常工作。
style="height:500px;background-image:url('assets/img/mypicture.jpg');
style="height:500px;background-image:url('./assets/img/mypicture.jpg');
style="height:500px;background-image:url('../assets/img/mypicture.jpg');
style="height:500px;background-image:url('https:/example.com/assets/img/mypicture.jpg');
,只有background:url();
谢谢!
答案 0 :(得分:0)
删除引号(单引号,双引号)。
background-image: url(assets/img/mypicture.jpg);
此外,在此处使用相对路径时要小心。还要检查这个问题:
Using relative URL in CSS file, what location is it relative to?