无法在php文件中显示css中的背景:url
问题是我有这个无法在php文件中显示css中的背景:url,php,html,css,Php,Html,Css,问题是我有这个 <header id="header"> </div> #header{ min-height:calc(100vh - 94px); background: linear-gradient(rgb(187, 139, 139),rgba(0, 0, 0, 0.5)), url(/images/image.png); background-position: center; background-size: co
<header id="header">
</div>
#header{
min-height:calc(100vh - 94px);
background: linear-gradient(rgb(187, 139, 139),rgba(0, 0, 0, 0.5)),
url(/images/image.png);
background-position: center;
background-size: cover;
background-attachment: fixed;
background-repeat: no-repeat;
position: relative;
}
当我从index.html运行时,会显示image.png,但当我从.php文件输入时,它不会显示。似乎您的文件访问路径错误。在开头添加点或删除开头的第一条斜线。例如:
background: linear-gradient(rgb(187, 139, 139),rgba(0, 0, 0, 0.5)),
url("./images/image.png");
或
使用背景图像:url(“~/images/image.png”);&背景色:线性渐变(rgb(187139139),rgba(0,0,0,0.5));
background: linear-gradient(rgb(187, 139, 139),rgba(0, 0, 0, 0.5)),
url("images/image.png");