我有一个带有 body
和 header 元素
的简单 html 页面:
<body>
<header class="logoBar"></header>
</body>
我尝试将背景图像添加到 header
。如果我这样做:
.logoBar {
background:url('http://img704.imageshack.us/img704/2162/67726065.jpg') repeat-x center top;
}
它不显示图像。但是如果我做:
body {
background:url('http://img704.imageshack.us/img704/2162/67726065.jpg') repeat-x center top;
}
我看到图片了。为什么它不适用于 header
?
谢谢。
最佳答案
尝试在标题元素的 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;
}
关于html - 标题不显示背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15969870/