css 单行文字垂直居中,单排字体内容垂直居中

 

css 单行笔墨垂直居中,单排字体内容垂直居中若何实现?

要让对象内只有一排(一行)的内容垂直居中,应用css行高(line-height)就可实现。

让行高line-height与对象高度height花色值设置相同即可。

div css实例演示代码:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>单排翰墨垂直居中实例 CSS5</title>
<style>
.exp{height:300px; line-height:300px; border:2px solid #F00}
</style>
</head>
<body>
<div class="exp">
单排文字垂直居中实例
</div>
</body>
</html>

成绩截图

CSS 笔墨垂直居中实现成效截图