将'div'垂直居中于%高度'div'中 [英] Center a 'div' vertically in a % height 'div'
本文介绍了将'div'垂直居中于%高度'div'中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将 div 垂直居中放置在百分比高度 div 中?
Is it possible to center a div vertically in a % height div?
推荐答案
在这里以及整个互联网上,已经被问了足够多次了.
This has been asked enough times here as well as all over the Internet.
快速搜索将为您带来大量结果.无论如何,我首选的方式是使用display: table-cell;
和vertical-align: middle;
.有关示例,请参见此页面. (请注意,这不适用于 Internet Explorer 6 .)
A quick search will bring you tons of results. Anyhow, my preferred way of doing this is to use display: table-cell;
and vertical-align: middle;
. See this page for an example. (Beware that this doesn't work on Internet Explorer 6.)
这篇关于将'div'垂直居中于%高度'div'中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文