表中的宽度 [英] width in table

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

问题描述




也许这是一个简单的问题,但我似乎无法让它发挥作用。

让我们说我有这张桌子:


< table style =" width:300px">

< tr>

< th>标题< / th>

< td> 1< / td>

< td> 22< / td>

< td> 333< / td>

< / tr>

< / table>


怎么能我使用CSS 2来获得最小宽度,让其他

列将宽度的其余部分平均分配。另外我不知道有多少

数据列。

Hi,

Maybe this is a simple question, but I can''t seem to get it to work.
Let''s say I have this table:

<table style="width: 300px">
<tr>
<th>Header</th>
<td>1</td>
<td>22</td>
<td>333</td>
</tr>
</table>

How can I use CSS 2 to make the th take minimal width and let the other
columns divide the rest of width equally. Also I do not know how many
data columns I have.

推荐答案

Robert< ro **** @ noreply.x>写道:
Robert <ro****@noreply.x> wrote:
也许这是一个简单的问题,但我似乎无法让它工作。
让我们说我有这张桌子:

< table style =" width:300px">
< tr>
< th> Header< / th>
< td> 1< / td>
< td> 22< / td>
< td> 333< / td>
< / tr>
< / table>

如何使用CSS 2来获取最小宽度,让其他
列平均分割宽度的其余部分。另外我不知道我有多少数据列。
Maybe this is a simple question, but I can''t seem to get it to work.
Let''s say I have this table:

<table style="width: 300px">
<tr>
<th>Header</th>
<td>1</td>
<td>22</td>
<td>333</td>
</tr>
</table>

How can I use CSS 2 to make the th take minimal width and let the other
columns divide the rest of width equally. Also I do not know how many
data columns I have.



http://homepage.ntlworld.com/spartanicus/robert.htm


请注意,这很难想象修复

表格宽度的正当理由,特别是在使用px单位和内容包含

文本时。如果表格用于布局目的,那么正确答案

就是停止这样做。


-

Spartanicus



http://homepage.ntlworld.com/spartanicus/robert.htm

Note that it''s hard to imagine a valid reason to fix the width of a
table, especially when using the px unit and when the content contains
text. If the table is used for layout purposes then the correct answer
is stop doing that.

--
Spartanicus


罗伯特写于2005年4月26日:
Robert wrote on 26/04/2005 :


也许这是一个简单的问题,但我可以似乎让它起作用。
让我们说我有这张桌子:

< table style =" width:300px">
< ; tr>
< th> Header< / th>
< td> 1< / td>
< td> 22< / td>
< td> 333< / td>
< / tr>
< / table>

如何使用CSS 2来获取最小宽度,让另一个
列将宽度的其余部分平均分配。另外我不知道我有多少数据列。
Hi,

Maybe this is a simple question, but I can''t seem to get it to work.
Let''s say I have this table:

<table style="width: 300px">
<tr>
<th>Header</th>
<td>1</td>
<td>22</td>
<td>333</td>
</tr>
</table>

How can I use CSS 2 to make the th take minimal width and let the other
columns divide the rest of width equally. Also I do not know how many data
columns I have.




因为你不知道你将拥有的列数,我猜是

这些是动态构建的。那是对的吗?如果是这样,那么也许

你可以进行litle运行时宽度计算....

< psuedo_sorta_code>

var_width = 100 /(var_column_count + 1); //为< th>添加一个
将var_width写入HTML模板中的宽度占位符。

(也许是search_replace var_width占位符。

< / psuedo_sorta_code>


您的HTML模板可能如下所示。


< table style =" width:300px" ;>

< tr>

< th style =" width:{var_width}%;">标题< / th>

< td style =" width:{var_width}%;"> 1< / td>

< td style =" width:{var_width}%;" ;> 22< / td>

< td style =" width:{var_width}%;"> 333< / td>

< / tr>

< / table>


-

a牛肉干网站 http://www.choicebeefjerky.com.au

不是牛肉干的网站 http://mycoolwheels.com/vote.cmks

没有人梦想为这个男人工作



as you dont know the amount of columns you will have, I am guessing
that these are built dynamically. is that correct? if so, then perhaps
you could do a litle run-time width calculations....
<psuedo_sorta_code>
var_width = 100 / (var_column_count + 1) ; // add one for the <th>
write the var_width to the width placeholder in the HTML template.
(perhaps search_replace the var_width placeholder.
</psuedo_sorta_code>

your HTML template may look like this.

<table style="width: 300px">
<tr>
<th style="width:{var_width}%;">Header</th>
<td style="width:{var_width}%;">1</td>
<td style="width:{var_width}%;">22</td>
<td style="width:{var_width}%;">333</td>
</tr>
</table>

--
a beef jerky site http://www.choicebeefjerky.com.au
not a beef jerky site http://mycoolwheels.com/vote.cmks
nobody ever dreams of working for the man


Spartanicus写道:
Spartanicus wrote:
Robert < RO **** @ noreply.x>写道:

Robert <ro****@noreply.x> wrote:

也许这是一个简单的问题,但我似乎无法让它发挥作用。
让我们说我有这个table:

< table style =" width:300px">
< tr>
< th>标题< / th>
< td> 1< / td>
< td> 22< / td>
< td> 333< / td>
< / tr>
< / table> ;

我如何使用CSS 2来获取最小宽度,让其他
列平均分配宽度的其余部分。另外我不知道我有多少数据列。

http://homepage.ntlworld.com/spartanicus/robert.htm
Maybe this is a simple question, but I can''t seem to get it to work.
Let''s say I have this table:

<table style="width: 300px">
<tr>
<th>Header</th>
<td>1</td>
<td>22</td>
<td>333</td>
</tr>
</table>

How can I use CSS 2 to make the th take minimal width and let the other
columns divide the rest of width equally. Also I do not know how many
data columns I have.

http://homepage.ntlworld.com/spartanicus/robert.htm




这仅适用于TD列的数量确切地说是3.

请注意,很难想象确定
表宽度的正当理由,特别是在使用px单元时以及内容包含
文字。


因为我喜欢我生成的其他表格大小相同。

如果表格用于布局目的那么正确答案
停止这样做。



This only works if the number of TD columns are exactly 3.
Note that it''s hard to imagine a valid reason to fix the width of a
table, especially when using the px unit and when the content contains
text.
Because I like the other tables I generate to be of equal size.
If the table is used for layout purposes then the correct answer
is stop doing that.




不,这不是图像的布局或类似的东西。



No, it''s not for the layout of images or something like that.


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

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