我正在尝试从 style.css 链接到 WordPress 插件文件夹中的图像。我尝试了以下但不起作用:
.example {
background: url( images/photo.jpg ) center center no-repeat;
}
插件文件夹图片:/wp-content/plugins/my-plugin/images/photo.jpg
样式表在这里:/wp-content/themes/my-theme/style.css
最佳答案
我知道您添加了“相对路径”标签,但您是否尝试过使用绝对路径,包括域名?
考虑尝试
.example {
background: url('http://full-path.com/wp-content/plugins/my-plugin/images/photo.jpg') center center no-repeat;
}
如果你想使用相对路径,看起来你也可以尝试:
../../plugins/my-plugin/images/photo.jpg
这假设服务器正在从 CSS 所在的文件夹中查找以解析照片的路径。 “..”表示向上移动一个目录级别。
希望对您有所帮助!
关于css - 如何从 style.css 链接到 WordPress 插件文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24363921/