显然我没有做对。我正在尝试将我的 Logo 放在 .head 标题的顶部。我该怎么做呢?当我按照下面提供的方式执行此操作时,我的图像会弹出到标题上方而不是标题上。
标记
<img src="\logo.png" width="96" height="82">
<div class="head"></div>
CSS
.head {background-image:url('header_bg.png'); top repeat-x; height: 110px;}
body {padding:0; margin:0;}
最佳答案
把图片标签放在div里面?
<div class="head">
<img src="\logo.png" width="96" height="82">
</div>
img
在 div 中居中的示例,仅水平:
<div class="head">
<img src="http://placekitten.com/200/100">
</div>
.head {
width: 300px; height: 300px;
background: transparent url(http://placekitten.com/300/300) no-repeat;
}
.head img {
display: block;
margin: 0 auto;
}
关于html - 图片位于背景图片之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16508865/