如何做出一个100%宽度的表,所有的列都等宽? [英] How do you make a 100% width table with the columns all equal width?

查看:412
本文介绍了如何做出一个100%宽度的表,所有的列都等宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个表,其中100%的页面(或其中的任何容器,取决于我使用的位置)。

I'm trying to make a table that stretches 100% of the page (or whatever container it's in, depending on where I use it).

当我指定表的宽度为100%,它会根据其内容的宽度自动调整列的大小。这是很好的大多数时候,我不介意不同的宽度列,但为此,我需要所有的列是相同的宽度。我知道我可以为列指定一个百分比宽度,但我需要这个工作任何数量的列。

When I specify the width of the table to 100%, it automatically resizes the columns based on the width of their content. This is nice most of the time when I wouldn't mind different width columns, but for this, I need all of the columns to be the same width. I know that I could specify a percentage width for the columns, but I need this to work for any number of columns.

这里是我的代码到目前为止:http://jsfiddle.net/zwWHZ/2/

Here's my code so far: http://jsfiddle.net/zwWHZ/2/

是否可以具有宽度为100%且列宽相同的表格,而不必使用纯CSS指定每个列的百分比?

Is it possible to have a table with a width of 100% and equal column widths without having to specify the percent for each column with pure CSS?

推荐答案

我尝试把 table-layout:fixed; 放入CSS的 ,并且似乎工作(即使我改变列数)。我发现的来源是此处

I tried putting table-layout: fixed; into the table section of the CSS, and that appeared to work (even when I changed the number of columns). The source where I found that is here.

这篇关于如何做出一个100%宽度的表,所有的列都等宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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