Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wordpress css精灵加载图像_Css_Wordpress_Sprite - Fatal编程技术网

wordpress css精灵加载图像

wordpress css精灵加载图像,css,wordpress,sprite,Css,Wordpress,Sprite,我正试图在我的wordpress项目中使用这样的精灵。但我在css加载背景图像时遇到了麻烦。加载页面后,我在控制台中检查了路径,url路径很好,但我有一个404错误 我的css: #navlist { position: relative; } #navlist li { margin: 0; padding: 0; list-style: none; position: absolute; top: 0; width : 44px; }

我正试图在我的wordpress项目中使用这样的精灵。但我在css加载背景图像时遇到了麻烦。加载页面后,我在控制台中检查了路径,url路径很好,但我有一个404错误

我的css:

#navlist {
    position: relative;
}

#navlist li {
    margin: 0;
    padding: 0;
    list-style: none;
    position: absolute;
    top: 0;
    width : 44px;
}

#navlist li, #navlist a {
    height: 44px;
    display: block;
}

#facebook {
    left: 0px;
    background: url('/wp-content/themes/montheme/images/facebook.png') 0 0;
}
控制台中的错误消息:加载资源失败:服务器响应状态为404(未找到)


有人有解决方案吗?

您不需要使用
/wp content/themes/montheme/
您可以将其称为:

background: url("images/facebook.png") 0 0;
background: url("<?php bloginfo('template_directory'); ?>/images/facebook.png") 0 0;
如果你的图像和CSS存在于你的主题中。另一种方法是将其添加到functions.php中,并将其称为:

background: url("images/facebook.png") 0 0;
background: url("<?php bloginfo('template_directory'); ?>/images/facebook.png") 0 0;
background:url(“/images/facebook.png”)0;

你能试试吗。/wp content/。。。?如果有效,请告诉我。否:/仍然无效