如何使用CSS使表居中 [英] How do I center a table using CSS

查看:93
本文介绍了如何使用CSS使表居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用CSS将表格居中?



在Site.css中

How do I center a table using CSS?

In Site.css

.centering{margin-left:auto;margin-right:auto;}



Default.aspx


Default.aspx

<table class="centering">
...
</table>

推荐答案

这个想法是正确的,但首先你要关心是宽度。首先,元素可以占用页面或父元素的整个宽度。比如说,您可以从更通用的表格样式继承它。在这种情况下,您居中,但您需要一个居中的房间。因此,请确保要居中的元素的宽度有限。它可以通过表格的内容来定义(默认),也可以使用百分比。



请参阅: http://webdesign.about.com/od/beginningcss/a/aa012207.htm



-SA
The idea is correct, but first thing you should care of is the width. First of all, the element may take the whole width of the page or parent element. Say, you can inherit it from your more general table style. In this case, you center, but you need a room to center in. So, make sure the element to be centered is limited in width. It could be defined by content of the table (default), or you can use percentage.

Please see: http://webdesign.about.com/od/beginningcss/a/aa012207.htm.

—SA


这篇关于如何使用CSS使表居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆