如何垂直居中块级元素? [英] How to center a block level element vertically?
本文介绍了如何垂直居中块级元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< table style =margin-left:auto; margin-right:汽车;>
< tr>
< td>
< / td>
< / tr>
< / table>
是否有类似的方式来垂直居中元素?
解决方案
这是一个经常要求做的事情。没有简单的方法来做垂直对齐。有 vertical-align
属性,但它是用于内联元素的行对齐。查看此链接,了解以不同方式进行垂直居中。
编辑:这是另一个链接,可以帮助您入门。
Say I have a like so:
<table style="margin-left: auto; margin-right: auto;">
<tr>
<td>
</td>
</tr>
</table>
The margin-*
attributes instruct the table to center itself within its parent element.
Is there a similar way to center the element vertically?
解决方案
This is a very often requested thing to do. There's no simple way to do vertical alignment. There's the vertical-align
attribute, but it's for line-alignment of an inline element. Check out this link for different ways to do vertical-centering.
Edit: Here's another good link to get you started.
这篇关于如何垂直居中块级元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文