如何将表格居中

本文探讨了为何100%高度的表格在不同浏览器和渲染模式下表现不一致的问题,以及如何通过合法的CSS代码实现表格的垂直居中。在标准模式下,由于HTML和BODY元素未填充浏览器视口高度,导致100%高度失效。解决方案是通过CSS设置HTML和BODY的高度为100%,并使用CSS为特定表格设置高度,以达到垂直居中的效果。
摘要由CSDN通过智能技术生成

http://blog.csdn.net/natineprince/archive/2009/09/01/4508099.aspx

100% Table Height

Occasionally designers may want to center content in a web page and they want it centered both horizontally and vertically. The traditional method for doing that is to put the content into a table and to assign a values of 100% to the table's de<HEIGHTde< attribute and center to the de<ALIGNde< attribute. Recently, that approach has become more problematic.

You may have used this before and had it work but now, for some reason, new pages you create won't center vertically. You may be changing pages from standard HTML to XHTML and now tables don't respect the 100% de<HEIGHTde< attribute. Read on.

There are a few things you need to know here. There is not now, nor has there ever been a de<HEIGHTde< attribute for tables. Scour the HTML specifications and you will not find de<HEIGHTde< among the attributes for the table tag. The fact is, table height is invalid code. If you attempt to validate a page where you have assigned a height to a table, it will fail. Assigning a height to the table tag is not the answer. You can, however, legally assign a height using CSS.

Rendering Modes

But why, you ask, di

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值