【发布时间】:2017-11-07 23:11:29
【问题描述】:
如何将 background-image: url() 与 php 结合使用以获得我要显示的图像的目录。
CSS
.imageGallery {
width: 960px;
position: relative;
background-image: url('<?php bloginfo("template_directory");?>/images/visitus.png');
}
目前,这个 css 不工作。不显示背景图片。
HTML
<div class="imageGallery">
</div>
例如:
这很好用
<img src='<?php bloginfo("template_directory");?>/images/home.png' class="headImage" />
但这不是
background-image: url('<?php bloginfo("template_directory");?>/images/visitus.png');
【问题讨论】:
-
Web 服务器错误日志显示 visitus.png 的 404?如果您查看源代码,您是否看到它呈现您期望的目录?如果您直接访问该目录,您可以加载文件吗?如果 home.png 有效,我会暂时为您的背景图片尝试。
-
你的css文件在哪里?在根目录中?