html table cell width for different rows [duplicate]

匿名 (未验证) 提交于 2019-12-03 01:29:01

问题:

Possible Duplicate:
table cell width issue

I have a table set up as

   
25 50 25
50 30 20

How do i get the 2 rows to have different cell width?

回答1:

As far as i know that is impossible and that makes sense since what you are trying to do is against the idea of tabular data presentation. You could however put the data in multiple tables and remove any padding and margins in between them to achieve the same result, at least visibly. Something along the lines of:

     
25 50 25
50 30 20
16 68 16

JSFIDDLE

I don't know your requirements but i'm sure there's a more elegant solution.



回答2:

One solution would be to divide your table into 20 columns of 5% width each, then use colspan on each real column to get the desired width, like this:

  
25 50 25
50 30 20

JSFIDDLE



回答3:

You can't have cells of arbitrarily different widths, this is generally a standard behaviour of tables from any space, e.g. Excel, otherwise it's no longer a table but just a list of text.

You can however have cells span multiple columns, such as:

25 50 25
75 20

As an aside, you should avoid using style attributes like border and bgcolor and prefer CSS for those.



回答4:

with 5 columns and colspan, this is possible (click here) (but doesn't make much sense to me):

25 50 25
50 30 20


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!