现在的位置: 首页 > 综合 > 正文

css-多行文字固定高度垂直居中(ie6.7.8.9 chrome ff)

2013年11月17日 ⁄ 综合 ⁄ 共 661字 ⁄ 字号 评论关闭
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title></title>
</head>
<style type="text/css">
	*{padding: 0;margin: 0;}
	.box{width: 400px;height: 400px;border: solid 5px red;}
	.txt,.bug{display: inline-block;vertical-align: middle;*display:inline;zoom:1;}
	.txt{}
	.bug{height: 100%;width: 1px;}
</style>
<body>
	<div class="box">
		<p class="txt">你妹啊妹啊<br>你妹啊妹啊</p>
		<p class="bug"></p>
	</div>
</body>
</html>

利用vertical-align居中的方法让文字相对于后面p标签一起居中

更多可参考大漠空间http://www.w3cplus.com/css/vertically-center-content-with-css

抱歉!评论已关闭.