HTML和CSS-垂直对齐div [英] HTML and CSS - Vertical align divs

查看:53
本文介绍了HTML和CSS-垂直对齐div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在左侧有一个div,在右侧有文本。文本可以是2行或3行,我希望左div垂直于该文本居中。我在网上看过,似乎所有不使用表格的方式都很复杂。有简单的方法吗?

I have a div on the left hand side, and text on the right hand side. The text can be either 2 or 3 lines long, and I want the left hand div to be vertically centered to that text. I've looked online and it seems that all the ways to do this without using tables are complicated. Is there an easy way to do this?

大多数建议似乎都指向 http://www.jakpsatweb.cz/css/css-vertical-center-solution.html ,其中使用了 CSS表。 CSS表格走了吗?

Most suggestions seem to point to http://www.jakpsatweb.cz/css/css-vertical-center-solution.html which uses "CSS tables". Are CSS tables the way to go? Is that really better than just using HTML tables?

推荐答案

是的,CSS表比HTML表要好,因为它们并不意味着任何HTML表。

Yes, CSS tables are better than HTML tables because they do not imply any semantic meaning but are explicitly used to describe presentation.

但是,对于您而言,CSS的 vertical-align 可以工作。例如: http://jsbin.com/itoyo3/edit

However, for your case CSS's vertical-align works. For example: http://jsbin.com/itoyo3/edit.

这篇关于HTML和CSS-垂直对齐div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆