【问题标题】:Vertical alignment and distribution of rows in table表格中行的垂直对齐和分布
【发布时间】:2017-02-25 09:37:25
【问题描述】:

第二列跨越 2 行。我希望第一列不要每行除以 50%。第 2 行应该从第 1 行的内容开始。

<table border="1" style="width:850px">
    <tr>
        <td style="width: 50%; vertical-align: top;">1.Row Cell 1</td>
        <td rowspan="2" style="height:800px">1-2 Row Cell 2</td>
    </tr>
    <tr style="vertical-align:top">
        <td style="vertical-align:top">2.Row Cell 1</td>
    </tr>
</table>

好的,看来这与Internet Explorer 11有关,但必须有办法做到这一点!?

【问题讨论】:

标签: html css internet-explorer-11 vertical-alignment


【解决方案1】:

所以下面的sn-p中有你的解决方案:

table , td, th {
	border: 1px solid #595959;
	border-collapse: collapse;
}
td, th {
	padding: 3px;
	width: 250px;
	height: 150px;
}
th {
	background: #f0e6cc;
}
.even {
	background: #fbf8f0;
}
.odd {
	background: #fefcf9;
}
<table>
	<tbody>
		<tr>
			<td style="height:1em">This is a test thank you for your attention</td>
			<td rowspan="2"></td>
		</tr>
		<tr>
			<td></td>
		</tr>
	</tbody>
</table>

希望对您有所帮助。

【讨论】:

  • 好吧,它适用于您发布的截图,但是当我在我的案例中使用代码时,一切都变得一团糟,我无法调整尺寸 - height: 150px 应该做什么?我在那个表中有 GridViews、Formviews 和 Repeater。
  • 能否请您提供完整的html css代码来帮助您。
  • 原始代码太长了,但如果你能帮助我获得我发布的示例工作?右列的大小为 800 像素。总宽度为 850 像素,每列占 50%。如果您能帮助我,那就太好了。
  • 所以你想让所有表格的宽度为 850px ,并且两列彼此相等?
  • 停下,我明白了。我坏了
【解决方案2】:

添加height: 1em; 似乎有效 - 就像第一个单元格这样:

&lt;td style="width: 50%; vertical-align: top; height: 1em;"&gt;

【讨论】:

  • 不,它不适合我:(
  • This fiddle 似乎有效?还是我误解了您要查找的内容?您正在尝试哪种浏览器?我尝试了 firefox 和 chrome - 似乎两者的工作方式相同?
  • 不,它看起来不像我想要的那样。我使用的是 Internet Explorer 11
  • 我检查了 Opera 中的小提琴,它可以工作。不幸的是,我必须使用 IE11。为什么???怎么办... grrrr
  • Ken,在 Nadim 的帮助下,我设法完成了这项工作。您的建议是正确的,但在 IE11 中您还需要定义最后一行的高度。我在你的小提琴里试过,看起来很酷。
猜你喜欢
  • 1970-01-01
  • 2018-09-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多