如何使用css在html中垂直居中文本 [英] how to center text vertically in html using css only

查看:219
本文介绍了如何使用css在html中垂直居中文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的html。由于一些限制,我不能修改html内容。我想使用css垂直居中文本。

i have a very simple html. due to some limitations, i cannot modify the html content. I want to center the text vertically only using css.

<html>
<head>...</head>
<body>
<div>Ops, the webpage is currently not available</div>
</body>
</html>

请注意,html的大小可以是可变的。

Note that the size of the html can be variable.

此外,如果文本不能在一行中显示,则应将它分成多行。

In additional, if the text cannot be displayed in one line, it should be broken into multiple lines.

有可能吗?

推荐答案

适用于表中的内容。对于你的简单页面,你可以把内容放在一个表而不是一个div,以避免这个问题。

I think vertical-align only works for content which is in a table. For your simple page you could put the content in a table instead of a div to avoid this problem.

有一些解决方法,参见 http://phrogz.net/css/vertical-align/index.html a>

There are some workarounds, see http://phrogz.net/css/vertical-align/index.html

这篇关于如何使用css在html中垂直居中文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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