Div 布局之 DIV垂直居中显示
2012-07-11 10:07
225 查看
中间放入表格 IE 火狐 chrome 测试通过
<html> <style>#a { background: #fff000; width: 500px; height: 500px; overflow: hidden; text-align: center;}</style> <body> <div id="a"> <table width="100%" height="100%"> <tr> <td align="center"> <img src="http://static.cnblogs.com/images/logo_small.gif" /> </td> </tr> </table> </div> </body></html>
中间放入表格 IE 测试通过
火狐 chrome 测试无效
<html> <style> #image{ width:500px; height:500px; background:#fff000; text-align: center; overflow: hidden; } #image img { vertical-align: middle; } #block { width: 0px; height: 100%; } </style> <body> <div id="image"> <img src="http://www.mm21.cn/dimg6/qqtu/201105/20110507234620615.jpg"/> <img src="" id="block"/> </div> </body></html>
<html> <style> #global1{ clear:left; width:100%; background:#000000; text-align: center; overflow: hidden; } #global{ width:800px; background:#FFFFFF; text-align: center; overflow: hidden; } #head{ width:800px; height:200px; background:#555555; text-align: center; overflow: hidden; } #left{ float:left; width:200px; height:700px; background:#888888; text-align: center; overflow: hidden; } #right{ float:left; width:600px; height:700px; background:#777777; text-align: center; overflow: hidden; } #bottom{ width:800px; height:150px; background:#666666; text-align: center; overflow: hidden; } </style> <body> <div id="global1"> <table width="100%" height="100%"> <tr> <td align="center"> <div id="global"> <div id="head"> head </div> <div id="left"> left </div> <div id="right"> right </div> <div id="bottom"> bottom </div> </div> </td> </tr> </table> </div> </body></html>
<html> <style>#a { background: #fff000; width: 500px; height: 500px; overflow: hidden; text-align: center;}</style> <body> <div id="a"> <table width="100%" height="100%"> <tr> <td align="center"> <img src="http://static.cnblogs.com/images/logo_small.gif" /> </td> </tr> </table> </div> </body></html>
中间放入表格 IE 测试通过
火狐 chrome 测试无效
<html> <style> #image{ width:500px; height:500px; background:#fff000; text-align: center; overflow: hidden; } #image img { vertical-align: middle; } #block { width: 0px; height: 100%; } </style> <body> <div id="image"> <img src="http://www.mm21.cn/dimg6/qqtu/201105/20110507234620615.jpg"/> <img src="" id="block"/> </div> </body></html>
<html> <style> #global1{ clear:left; width:100%; background:#000000; text-align: center; overflow: hidden; } #global{ width:800px; background:#FFFFFF; text-align: center; overflow: hidden; } #head{ width:800px; height:200px; background:#555555; text-align: center; overflow: hidden; } #left{ float:left; width:200px; height:700px; background:#888888; text-align: center; overflow: hidden; } #right{ float:left; width:600px; height:700px; background:#777777; text-align: center; overflow: hidden; } #bottom{ width:800px; height:150px; background:#666666; text-align: center; overflow: hidden; } </style> <body> <div id="global1"> <table width="100%" height="100%"> <tr> <td align="center"> <div id="global"> <div id="head"> head </div> <div id="left"> left </div> <div id="right"> right </div> <div id="bottom"> bottom </div> </div> </td> </tr> </table> </div> </body></html>
相关文章推荐
- div+css:页面整体布局居中显示:上下居中||垂直居中,左右居中||水平居中
- CSS3新特性,让文本在父布局垂直居中显示
- div固定高度中图片垂直居中显示
- 使用flex布局实现div垂直居中
- css控制一个div在其父级的div垂直居中显示
- CSS-布局【1】-图片在div中垂直居中
- DIV水平垂直居中显示
- div+css垂直居中显示
- 使用css3将一个div水平和垂直居中显示
- 用CSS3中的flexbox 布局模式使div内容垂直居中:
- CSS:使用CSS3将一个div水平和垂直居中显示
- JS+CSS设置img在DIV中只显示Img垂直居中的部分
- CSS布局:图片在DIV中上下左右居中(水平和垂直都居中)
- div 中image 垂直水平居中显示
- CSS在页面布局中实现div垂直居中的方法总结(转)
- CSS布局——DIV水平居中和垂直居中
- css控制一个div在其父级的div垂直居中显示
- 网页常见布局,让图片在div中,垂直居中,水平居中
- DIV布局的设置(水平或者垂直居中)
- Html+Css_div中的垂直居中布局