Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
赋予HTML表格单元格相对于其他单元格的优先级_Html_Css_Html Table - Fatal编程技术网

赋予HTML表格单元格相对于其他单元格的优先级

赋予HTML表格单元格相对于其他单元格的优先级,html,css,html-table,Html,Css,Html Table,我有一张非常简单的桌子: <table cellspacing=0 cellpading=0 border=0> <tr> <td width="50%">Here is column 1</td> <td width="50%">Here is column 2</td> </tr> </table> 这是第1栏 这是第二栏 有没有办法让第2列在第1列之前减少宽度?

我有一张非常简单的桌子:

<table cellspacing=0 cellpading=0 border=0>
  <tr>
     <td width="50%">Here is column 1</td>
     <td width="50%">Here is column 2</td>
  </tr>
</table>

这是第1栏
这是第二栏
有没有办法让第2列在第1列之前减少宽度?如果屏幕宽度变小,我希望第1列保持尽可能接近50%。但是,如果第2列不再有折叠的空间,则第1列可以收缩

我不想将“空白:nowrap”应用于第1列,也不想使用固定格式或javascript。是否有CSS解决方案?

您必须为第一列指定特定(非百分比)宽度(初始宽度可以根据初始窗口大小计算)

例如

HTML

<table cellspacing="0" cellpading="0" border="0">
  <tr>
     <td>Here is column 1</td>
     <td>Here is column 2</td>
  </tr>
</table>
演示


尝试将右下角窗口调整到右侧。

如果第一列要保持50%,您认为第二列的百分比是多少?想法是让第1列的行为就像“空白:nowrap”,但直到第2列尽可能缩小为止。在这一点上,第1列开始减少宽度是可以的。为什么我觉得您使用表格来布局非表格数据?这很有道理。希望有一个不同的选择,但效果很好。:)谢谢
table {
    font-size:40px
}

tr > td:first-child {
    width:280px;
}