如何在表中使用相同大小的可变列混合使用固定列和可变列?

时间:2021-09-30 23:01:01

I've got a HTML table that has four columns of data, retrieved from a SQL database. The table is styled with CSS to be the full width of the page. The first and third columns are of a fixed size. I want the other two columns to change size with the table but for the two variable width columns to always be the same size.

我有一个HTML表,它有四列数据,从SQL数据库中检索。该表使用CSS进行样式设置为页面的整个宽度。第一列和第三列具有固定大小。我希望其他两列用表更改大小,但两个可变宽度列总是相同的大小。

I've used these styles for columns 1 and 3 (the fixed widths) and the table:

我已经将这些样式用于第1列和第3列(固定宽度)和表格:

.column1
{
  min-width: 120px;
  width: 120px;
}

.column3
{
  min-width: 140px;
  width: 140px;
}

.mytable
{
  width: 100%;
}

I haven't set any styles for the two variable width columns. I find that in Firefox the table works as expected but in Internet Explorer the two variable width columns change size depending upon what text is present in the rows.

我没有为两个可变宽度列设置任何样式。我发现在Firefox中,表格按预期工作,但在Internet Explorer中,两个可变宽度列会根据行中存在的文本来更改大小。

How can I keep the two variable columns the same width?

如何保持两个变量列的宽度相同?

EDIT

Not sure if it's worth mentioning but some data crosses multiple columns with colspan="3". This isn't alwyas the case though and the table sizes in the same way whether such a row is present or not. The intention is to create a layout that matches that of a form in Microsoft CRM 4.0. A mix of four columns and two columns (colspan=3 on second column) and rows that can vary in height. It also means that this only needs to work in IE.

不确定是否值得一提,但有些数据与colspan =“3”交叉多列。这不是一种情况,并且表格以相同的方式确定是否存在这样的行。目的是创建一个与Microsoft CRM 4.0中的表单匹配的布局。四列两列的混合(第二列上的colspan = 3)和高度不同的行。这也意味着这只需要在IE中工作。

1 个解决方案

#1


0  

Since the width of your table is defined as a percentage, you might consider making .column1 and .column3 a percentage as well. This will then help you define the widths of the two remaining columns.

由于表的宽度定义为百分比,因此您可以考虑将.column1和.column3设为百分比。这将帮助您定义其余两列的宽度。

#1


0  

Since the width of your table is defined as a percentage, you might consider making .column1 and .column3 a percentage as well. This will then help you define the widths of the two remaining columns.

由于表的宽度定义为百分比,因此您可以考虑将.column1和.column3设为百分比。这将帮助您定义其余两列的宽度。