【发布时间】:2012-03-14 21:47:26
【问题描述】:
我有一个 div,其中包含一个覆盖有文本的图形背景。我想水平和垂直居中这个元素。但我无法让文本垂直居中。到目前为止,我有以下代码:
<div id="step">
<div id="background">
<img src="buttonbackground.png" class="stretch" alt="" />
</div>
<div>
<h3>some text</h3>
</div>
</div>
在 CSS 中:
#background {
width: 100%;
height: 100%;
position: absolute;
left: 0px;
z-index: -1;
}
#step {
text-align:center;
color:white;
}
.stretch {
width:200px;
height:40px;
}
使用我在其他地方经常引用的表格单元格/垂直对齐技术不太奏效。
【问题讨论】:
标签: css