本文介绍了向上延伸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个JavaScript时间轴,在其中点击左栏显示右栏中的内容。我想有更简单的方法来做到这一点,但下面的HTML看起来真的很干净。



所以通常的方式rowspan的作品是你有一个你想要的td向下延伸几行以完成表。

 < tr> 
< td> 1942< / td>
< td rowspan = 2>发生了什么< / td>
< / tr>
< tr>
< td> 2017< / td>
< / tr>

但是,如果我想向上行向上,那么下面时间表项填充两行?

 < tr> 
< td> 1942< / td>
< / tr>
< tr>
< td> 2017< / td>
< td rowspan = 2>发生了其他事情< / td>
< / tr>

我知道我可以将它们全部移动到顶部行和行距,但我真的很想有一个很好的,易于编辑的格式,日期和行紧挨着。



(我有一个想法,如果你认为rowspan是类似于css的宽度和高度,除了实际将td移动到你想要的tr之外,可能有类似于css left和top(比如table-row?)的东西,我不认为这是存在的, )



(还有人知道是否定义了负的行跨度吗?)解决方案

/ div>

不, rowspan 总是向下工作。 HTML 4没有明确地说出这一点,但它肯定是隐含的,并且没有办法改变它。 HTML5在它的无聊详细(但是对于实现者而言是必需的)中明确表示它。 l表格。


I'm trying to program a javascript timeline, in which you click on the left column revealing something in the right column. I suppose there are easier ways to do this, but the HTML below looks really really neat.

So the usual way rowspan works is that you have a td that you want to extend down a few rows to complete the table.

<tr>
    <td>1942</td>
    <td rowspan=2>Something happened</td>
</tr>
<tr>
    <td>2017</td>
</tr>

However, what if I want to rowspan upwards, so that the below timeline item fills both rows?

<tr>
    <td>1942</td>
</tr>
<tr>
    <td>2017</td>
    <td rowspan=2>Something else happened</td>
</tr>

I know I can just move them all to the top row and rowspan from there, but I really want to have this nice, easy-to-edit format, with dates and rows right next to each other.

(An idea I had was that if you think of rowspan as analogous to css width and height, there might be something analogous to css left and top (like "table-row"?) you could set, other than actually moving the td's to the tr you want. I don't think that exists, though.)

(also, does anyone know if negative rowspan is defined?)

解决方案

No, rowspan always works "downwards". HTML 4 does not explicitly say this, but it is definitely implied, and there is no way to change it. HTML5 makes it explicit, in its boringly detailed (but necessary for implementors) Processing model for tables.

这篇关于向上延伸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 03:15