请提供原文。
<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 :(
谢谢。