在样式表中定义时不显示背景图像 [英] Background image doesn't show when defined in stylesheet
本文介绍了在样式表中定义时不显示背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对CSS非常陌生,所以这也许是一个简单的答案.我有2种情况,其他1种情况没有.我希望有人能帮助我.
I am very new to css so this maybe a simple answer. I have 2 scenarios and 1 works the other doesn't. I hope someone can help me out.
作品:
<head>
<style type="text/css">
body {
background-image:url('views/default/images/home.jpg');
;}
</style>
</head>
不起作用:
<head>
<link rel="stylesheet" type="text/css" href="views/default/home_style.css" />
</head>
在home_style.css>
In home_style.css>
body{
background-image:url('views/default/images/home.jpg');
margin-top: 0px !important;
padding-top: 0px !important;
}
推荐答案
看起来您的CSS文件位于views/default/
文件夹中,而图像位于views/default/images/
文件夹中.
It looks like your CSS file is in the views/default/
folder, while the image is in the views/default/images/
folder.
相对于 CSS文件,而不是显示所有内容的HTML文件,在CSS中定义图像路径:
Define image paths in your CSS relative to the CSS file, not the HTML file that displays everything:
background-image:url('images/home.jpg');
这篇关于在样式表中定义时不显示背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文