How can I use background-image: url() in conjunction with php in order to obtain the directory of the image I would like to display.

我如何结合php使用background-image:url()来获取我想要显示的图像的目录。

CSS

CSS

.imageGallery {
width: 960px;
position: relative;
background-image: url('<?php bloginfo("template_directory");?>/images/visitus.png');
}

Currently, this css does not work. No background image is displayed.

目前,这个CSS不起作用。没有显示背景图像。

HTML

HTML

<div class="imageGallery">
</div>

For example:

例如:

this works fine

这很好用

<img src='<?php bloginfo("template_directory");?>/images/home.png' class="headImage" />

but this doesn't

但事实并非如此

    background-image: url('<?php bloginfo("template_directory");?>/images/visitus.png');

2 个解决方案

#1


1

You can try this two options bellow

你可以试试这两个选项

CSS

CSS

.imageGallery {
width: 960px;
position: relative;
background-image: url('images/visitus.png');
}

HTML with inline CSS

带内联CSS的HTML

<div class="imageGallery" style="background-image: url('<?php bloginfo("template_directory");?>/images/visitus.png')">
</div>

If you use the second option, you need to remove background image url from your css rule for that element. Hope it helps

如果使用第二个选项,则需要从css规则中删除该元素的背景图像URL。希望能帮助到你

更多相关文章

  1. 在PHP中将PDF文档转换为预览图像,而无需安装Ghostscript
  2. 我需要PHP页面显示mysql数据库中的BLOB图像
  3. php怎么读取MYSQL数据到radio选项
  4. 如何使用mysql在php文件夹中快速更改图像名称?
  5. 视差滚动与图像仅通过徽标透明度
  6. 具有固定宽度网格的引导程序和应跨越窗口宽度的图像
  7. 从文本框值生成条形码图像
  8. Div高度为图像高度,图像宽度为div宽度
  9. 如何在HTML选择选项列表中保留空间hi

随机推荐

  1. Android(安卓)Camera——拍照
  2. Android根据经纬度获取地址
  3. 向Android模拟器发短信打电话
  4. zxing-client-android 导入Android Studi
  5. android Content Provider的使用
  6. Android零碎知识点 1
  7. android基本布局
  8. Android OpenGL ES 开发教程 从入门到精
  9. SQlite字段类型升级
  10. android dialog小结