【发布时间】:2012-03-01 20:36:44
【问题描述】:
考虑以下 html:
<div class="image">
<img src="sample.png"/>
<div class="text">
Text of variable length
</div>
</div>
地点:
.image {
position:relative;
text-align:center; // doesn't work as desired :(
}
.text {
position:absolute;
top:30px;
}
你能告诉我,是否有办法在.image div 的中心水平对齐文本?我不能使用left 属性,因为文本的长度未知,并且text-align 属性不适用于.text div :(
谢谢。
【问题讨论】: