如何将表格单元格宽度设置为最小值(最后一列除外)? [英] How do I set the table cell widths to minimum except last column?

查看:136
本文介绍了如何将表格单元格宽度设置为最小值(最后一列除外)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个宽度为100%的表格。如果我把< td> 放在它里面,它们会被等长列分开。但是,我希望除最后一行之外的所有列都尽可能小,不包括文本。

I have a table with 100% width. If I put <td>s in it, they get spread out with equal length columns. However, I want all the columns except last to have as small a width as possible, without wrapping text.

我首先做的是设置 > width =1px width:1px没有任何效果),这工作正常,直到我有多字数据在列中。在这种情况下,为了保持尽可能小的长度,它包裹了我的文本。

What I did first was that I set width="1px" in all <td>s except last (although deprecated, but the style="width:1px" didn't have any effect), which worked fine until I had multi-word data in the column. In that case, to keep the length as small as possible, it wrapped my text.

让我演示。想象这张表:

Let me demonstrate. Imagine this table:

---------------------------------------------------------------------------------
element1 | data      | junk here   | last column
---------------------------------------------------------------------------------
elem     | more data | other stuff | again, last column
---------------------------------------------------------------------------------
more     | of        | these       | rows
---------------------------------------------------------------------------------

无论我尝试什么,我一直得到的是:

No matter what I try, what I keep getting is either this:

---------------------------------------------------------------------------------
element1         | data             | junk here        | last column
---------------------------------------------------------------------------------
elem             | more data        | other stuff      | again, last column
---------------------------------------------------------------------------------
more             | of               | these            | rows
---------------------------------------------------------------------------------

或者(即使我设置了 style =whitespace-wrap:nowrap)this:

or (even though I set style="whitespace-wrap:nowrap") this:

---------------------------------------------------------------------------------
         |      | junk  | last
element1 | data |       | 
         |      | here  | column
---------------------------------------------------------------------------------
         | more | other | again,
elem     |      |       | last
         | data | stuff | column
---------------------------------------------------------------------------------
more     | of   | these | rows
---------------------------------------------------------------------------------

我想获得我先提交的表。我如何实现这一点? (我宁愿坚持标准和使用CSS。我真的不在乎IE如何没有实现标准的一部分)

I want to get the table I presented first. How do I achieve this? (I'd rather stick to standard and using CSS. I honestly don't care if IE hasn't implemented part of the standard either)

更多解释:需要的是保持列尽可能短,不包装单词(最后一列应该大到需要使表宽度实际达到100%)。如果你知道LaTeX,我想要的是当你将它们的宽度设置为100%时,表格在LaTeX中自然出现。

More explanation: What I need is to keep the columns as short as possible without wrapping words (last column should be as large as it needs to make the table width actually reach 100%). If you know LaTeX, what I want is how tables naturally appear in LaTeX when you set their width to 100%.

注意:我发现这是,但它仍然给出

Note: I found this but it still gives me the same as last table.

推荐答案

whitespace-wrap:nowrap 是无效的css。 white-space:nowrap 您正在寻找。

whitespace-wrap: nowrap is not valid css. It's white-space: nowrap you're looking for.

这篇关于如何将表格单元格宽度设置为最小值(最后一列除外)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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