【css】多行文字图片混排容器内垂直居中解决方案
css:
.box-wrap{display:table;width:200px;height:200px;*position:relative;}/*最外边的容器,需固定宽高*/
.box-hack{display:table-cell;height:200px;vertical-align:middle;*position:absolute;*top:50%;}/*需要定义高度*/
.box-ctn{*position:relative;*top:-50%;}
html:
<div class="box-wrap">
<div class="box-hack">
<div class="box-ctn">
<img alt="图片" src="http://www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif">
<p>这是文字这是文字这是文字</p>
</div>
</div>
</div>
demo地址:
原文出自: http://note.youdao.com/share/?id=91293504345e960c53103935d5645c7c&type=note
- 上一篇 »CSS小技巧
- 下一篇 »css中元素水平垂直居中4种方法介绍