【发布时间】:2013-01-27 09:50:32
【问题描述】:
<div class="wrapper">
<div class="header">
<img id="back" />
<img id="front" />
</div>
<div class="body">
...
</div>
<div class="footer">
...
</div>
</div>
<style type="text/css">
.wrapper {
margin-left: auto;
margin-right: auto;
margin-top: -8px;
width: 1024px;
height: 1500px;
background-color: #CCC;
border: 1px solid;
/*display: run-in;*/
/*position:fixed;*/
text-align: center;
}
.header {
background-color: #FFC;
/*margin: 0 auto;*/
height: 150px;
width: 1000px;
display: box;
z-index: 10;
text-align:center;
vertical-align:middle;
position: fixed;
display:block;
}
#back {
position: relative;
width: 100%;
}
#front{
position: relative;
z-index: 10;
}
我需要将标题固定在页面顶部(包装器是固定宽度),包装器内的图像在标题内水平和垂直居中。如何实现?
好的。 澄清 Wrapper 是固定宽度的。 页眉应贴在页面顶部(包装器内部)并包含两张图片/图像。图像应相互重叠,并在标题内垂直和水平居中。 希望我现在足够精确。
【问题讨论】:
-
不得不说这个问题可能不应该回答,如果你改进你的问题,我会改进我的答案
-
当然,我会改进问题,不需要那样。
-
为什么你没有发布任何CSS? SO 的目的不是让人们为您编写代码,而是帮助您解决代码中的问题。您的问题中的任何内容都无法在网络搜索中轻松找到
-
图片尺寸?标题高度?您已经在使用任何其他 CSS 规则了吗?