0

左右,垂直居中的一个例子

/前端开发 /2008.06.17

前些天,利华说能不能让某个div或者其他块元素左右,及垂直居中,我想了一会,做了下面这个测试页面,在IE系列,FF,safari,opera下均通过。。主要是position的用法。。其实像很多light box使用的也是类似的方法:
css:
#bd{position:static;display:table-cell;}
#test{width:500px;height:500px;background:#DADADA;position:absolute;top:50%;left:50%;
margin-left:-250px;margin-top:-250px;}
structure:
< body id=”bd” >
< div id=”test” >< /div >
< /body >

demo here!!

(本文出自有意思Blog,转载时请注明出处)



发表评论

*称呼不能为空
*请输入正确的邮箱
*内容不能为空