Html WordPress CSS 背景图像未出现
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11329947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WordPress CSS Background images not appearing
提问by Tom
As said in the title, the background images for my website are not appearing. I am very new to wordpress. I have managed to get normal images in the HTML files to appear <img src="<?php echo get_bloginfo('template_url');?>/images/image01.jpg" alt="image description" width="1269" height="441" />
but for some reason, all the images in my css wont appear. I have done some research while trying to fix this problem, the most common answer is to format the css like so:
如标题所述,我网站的背景图片没有出现。我对 wordpress 很陌生。我已经设法让 HTML 文件中的普通图像出现,<img src="<?php echo get_bloginfo('template_url');?>/images/image01.jpg" alt="image description" width="1269" height="441" />
但由于某种原因,我的 css 中的所有图像都不会出现。我在尝试解决这个问题时做了一些研究,最常见的答案是像这样格式化 css:
.logo{
background:url("/images/logo.png") no-repeat; }
but this is not working.
但这不起作用。
Any help will be appreciated.
任何帮助将不胜感激。
Thanks in advance, Tom
提前致谢,汤姆
EDIT:
link to the stye.css in the header.php
file:
编辑:链接到header.php
文件中的 stye.css :
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
回答by menislici
Are you using this to import your stylesheet:
您是否使用它来导入您的样式表:
bloginfo('stylesheet_url');
it should go in the hreftag of the stylesheet linkand the style.css file itself should be in the same directory as index.php
它应该在样式表链接的href标签中,并且 style.css 文件本身应该与 index.php 位于同一目录中
Look at the code to be included in your head tag: http://jsfiddle.net/wpWbN/
查看要包含在您的 head 标签中的代码:http: //jsfiddle.net/wpWbN/
回答by Keerthi Kesavan
If You are Creating a theme from the scratch means...
如果您从头开始创建主题意味着...
*make sure your background image in image folder within your custom theme folder
*确保您的背景图像位于自定义主题文件夹中的图像文件夹中
*then include the image from your custom theme folder
*然后包含自定义主题文件夹中的图像
css file
css文件
.header{
background: url("../custom_theme_folder_name/images/123.png") repeat;
}
回答by DarthSinuhe
In my case my code is like the next line
在我的情况下,我的代码就像下一行
background: url("assets/images/icon.png");
my folders are
我的文件夹是
wp-content\themes\theme-name\assets\images
wp-content\themes\theme-name\assets\images
回答by Kashif Munir
did you try this?
你试过这个吗?
.logo{
background:url("images/logo.png");
}
回答by Ondrej
It's possible that the adress in your source attribute is not starting where you think it is (meaning you probably don't start from the root node). try this:
您的源属性中的地址可能不是从您认为的位置开始(意味着您可能不是从根节点开始)。尝试这个:
.logo{
background:url("../images/logo.png") no-repeat; }
or this
或这个
.logo{
background:url("../../images/logo.png") no-repeat; }