标题未显示背景图片 [英] Background image doesn't show for header
本文介绍了标题未显示背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有body
和header elements
的简单html页面:
I have simple html page with body
and header elements
:
<body>
<header class="logoBar"></header>
</body>
我尝试将背景图像添加到header
.如果我这样做:
I try to add background image to header
. If i do:
.logoBar {
background:url('http://img704.imageshack.us/img704/2162/67726065.jpg') repeat-x center top;
}
它不显示图像.但是如果我做:
It doesn't show image. But if i make:
body {
background:url('http://img704.imageshack.us/img704/2162/67726065.jpg') repeat-x center top;
}
我看到了图像.为什么不适用于header
?
I see image. Why doesn't it work for header
?
谢谢.
推荐答案
尝试在标头元素的CSS上设置宽度和高度.
Try setting a width and height on your header element's css.
.logoBar {
width: 100%;
height: 250px; <!-- Your image height goes here...
background:url('http://img704.imageshack.us/img704/2162/67726065.jpg') repeat-x center top;
}
这篇关于标题未显示背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文