【发布时间】:2014-04-16 02:53:29
【问题描述】:
我有 DIV,其中包含一些文本和一个按钮。我需要:
- 对齐DIV底部的按钮
- 对齐 DIV 顶部的文本
这是我想要的图像:
我的代码:
HTML:
<div class="table">
<div class="cell">
<p>Some text</p>
<a type="button" class="btn" href="#">Button</a>
</div>
<div class="cell">
<p>The big one text</p>
<a type="button" class="btn" href="#">Button</a>
</div>
<div class="cell">
<p>Some small text</p>
<a type="button" class="btn" href="#">Button</a>
</div>
</div>
CSS:
.table {
display: table;
}
.cell {
float: none;
display: table-cell;
height: auto;
}
.cell .btn {
vertical-align: bottom;
}
任何想法如何做到这一点?
【问题讨论】:
-
嗨.. 你应该看看这里。这可能会对你有所帮助。stackoverflow.com/questions/2743989/vertically-aligning-divs
-
你的 div 高度是固定的吗?
-
@RiteshChandora 不,他们不是。
-
@ba1ar 谢谢我会读的。
标签: html css vertical-alignment css-tables