单元格边框上的HTML表格标题 [英] HTML table header over cell borders

查看:124
本文介绍了单元格边框上的HTML表格标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在HTML标记(或可能是CSS)中是否可以指定HTML表格的标题应放在单元格上方

边框而不是''在'单元内'。


例如(需要等宽字体):


默认值:

+ -------------------- +

| H1 H2 H3 |

| C1 | C2 | C3 |

+ -------------------- +


所需:

+ -------------------- +

| H1 H2 |

+ -------------------- +

| C1 | C2 | C3 |

+ -------------------- +

解决方案

Grant Kelly写道:


我想知道在HTML标记(或可能是CSS)中是否可能

指定HTML表格的标题应放在单元格上方,而不是单元格内。

例如(需要等宽字体):


默认值:

+ -------------- ------ +

| H1 H2 H3 |

| C1 | C2 | C3 |

+ -------------------- +


所需:

+ -------------------- +

| H1 H2 |

+ -------------------- +

| C1 | C2 | C3 |

+ -------------------- +



单程将使C1,C2和C3的COLSPAN为2并且给出H1和

H2也是2的COLSPAN但是在开头包括一个表格单元格

标题行的结尾。


Scripsit PDannyD:


Grant Kelly写道:
< blockquote class =post_quotes>
>我想知道在HTML标记(或可能是CSS)中是否可以指定应放置HTML表格的标题'过''的细胞边界而不是细胞内。



- -


一种方法是让C1,C2和C3有一个COLSPAN为2并且给出了b $ b H1和H2的COLSPAN为2,但在标题行的开头和结尾处包含一个表格单元格。



你不需要虚拟细胞。相反,你可以这样写:


< table>

< tr>< th colspan =" 3"> A< / th> < th colspan =" 3" B< / th>< / tr>

< tr>< td colspan =" 2"> C1< / td>< ; td colspan =" 2"> C2< / td>< td

colspan =" 2"> C3< / td>< / tr>

< / table>


可能需要一些样式来将A和B标题放在

边框的正上方。


但这有什么可能证明这种混乱?它不会说清楚

什么是标题,它会混淆基于语音的用户代理

(至少除非你添加一些额外的标记,id和标题属性)。


-

Jukka K. Korpela(Yucca)
http://www.cs.tut.fi/~jkorpela/


6月7日00:09,Grant Kelly< gke ... @ gmail.comwrote:


I'我想知道是否可以在HTML标记(或可能是CSS)中指定HTML表格的标题应该放在单元格上面

边界而不是''在'单元内'。



我能想到的唯一可以想象的情况是合理的,因为合理的语义标记将适用于三个状态。在细胞中

和两个过渡他们之间的标题。在那种情况下,我会使用5列,虚拟单元格和一些colspan属性来
。详细,但

可用于大多数解释。


作为一种更简单实用的方法,我会在
$中使用两个单元格b $ b标题,第二个是colspan = 2,只需使用一些左边填充

" offset"标题远离其正常位置。您甚至可以通过使用text-align:right来实现
。他们没有colspan。


I''m wondering if it''s possible within HTML markup (or possibly CSS) to
specify that an HTML table''s headers should be placed ''over'' the cell
borders rather than ''within'' the cells.

For example (requires monospace font):

Default:
+--------------------+
| H1 H2 H3 |
+--------------------+
| C1 | C2 | C3 |
+--------------------+

Desired:
+--------------------+
| H1 H2 |
+--------------------+
| C1 | C2 | C3 |
+--------------------+

解决方案

Grant Kelly wrote:

I''m wondering if it''s possible within HTML markup (or possibly CSS) to
specify that an HTML table''s headers should be placed ''over'' the cell
borders rather than ''within'' the cells.

For example (requires monospace font):

Default:
+--------------------+
| H1 H2 H3 |
+--------------------+
| C1 | C2 | C3 |
+--------------------+

Desired:
+--------------------+
| H1 H2 |
+--------------------+
| C1 | C2 | C3 |
+--------------------+

One way would be to make C1, C2 and C3 have a COLSPAN of 2 and give H1 and
H2 a COLSPAN of 2 as well but include a single table cell at the beginning
and end of the header row.


Scripsit PDannyD:

Grant Kelly wrote:

>I''m wondering if it''s possible within HTML markup (or possibly CSS)
to specify that an HTML table''s headers should be placed ''over'' the
cell borders rather than ''within'' the cells.

- -

One way would be to make C1, C2 and C3 have a COLSPAN of 2 and give
H1 and H2 a COLSPAN of 2 as well but include a single table cell at
the beginning and end of the header row.

You don''t need dummy cells. Instead, you could write:

<table>
<tr><th colspan="3">A</th><th colspan="3">B</th></tr>
<tr><td colspan="2">C1</td><td colspan="2">C2</td><td
colspan="2">C3</td></tr>
</table>

Some styling might be needed to position the A and B headers right above the
borders.

But what could possibly justify this confusion? It would not make it clear
what is a header for which, and it would confuse speech-based user agents
(at least unless you add some extra markup, with id and headers attributes).

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


On 7 Jun, 00:09, Grant Kelly <gke...@gmail.comwrote:

I''m wondering if it''s possible within HTML markup (or possibly CSS) to
specify that an HTML table''s headers should be placed ''over'' the cell
borders rather than ''within'' the cells.

The only conceivable situation I can think of that justifies this as
reasonable semantic markup would be for three "states" in the cells
and two "transitions" between them in the headers. In that case I''d
use 5 columns, dummy cells and some colspan attributes. Verbose, but
jusifiable for most interpretations.

As a much simpler and pragmatic approach, I''d use two cells in the
header, colspan=2 on the second one and just use some left padding to
"offset" the headers away from their normal position. You might even
do it just by using text-align:right; on them and no colspan.


这篇关于单元格边框上的HTML表格标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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