这里的一个例子是,在权利上增加了浮动的DIV,并将案文纵向和横向地集中起来。
http://jsfiddle.net/johnpa/pUr6T/
The trick here is to set the line-height of the element to be the full height of its container.
<div id="outerDiv">
<div id="rightFloatingDiv">
<p>Hello</p>
</div>
<p>Lorem ipsum dumsome Lorem ipsum dumsome Lorem ipsum </p>
</div>
#outerDiv{
width:400px;
height:400px;
background:#EEAAEE;
}
#rightFloatingDiv{
width:100px;
height:100px;
line-height:100px;
background:#EEEEEE;
float:right;
}
#rightFloatingDiv > p{
width: 100%;
height: 100%;
line-height:inherit;
background:yellow;
vertical-align:middle;
text-align:center;
}