微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 Asciidoc 中为表格标题、行和单元格元素添加特定的 css 属性

如何解决如何在 Asciidoc 中为表格标题、行和单元格元素添加特定的 css 属性

可以在 asciidoc 中向表中添加特定的类,如下所示:

asciidoc

[.custom]
[cols="40a,80a",options="header"]
|===

|First Name
|Family Name

|John
|Smith

|==

HTML(Antora 运行后)

<table class="tableblock frame-all grid-all stretch custom">
..
..
<thead>
<tr>
<th class="tableblock halign-left valign-top"><strong>First Name</strong></th>
<th class="tableblock halign-left valign-top"><strong>Family Name</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph"><p>John</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph"><p>Smith</p></div></div></td>
</tr>

因此,“自定义”的“角色”已应用于

元素。 但是,我还想为 和
元素指定特定的属性。 我该怎么做?

我已经尝试过:

|[.custom]First Name

对于第一个元素,并且:

|[.custom]John

对于 td 元素

但这只会在转换为 html 时给我以下内容

<th class="tableblock halign-left valign-top"><strong class="custom">First Name</strong> 
</th>
..
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph"><p>[.custom]John</p></div></div></td>

我如何实现以下目标:

<th class="tableblock halign-left valign-top custom"><strong>First Name</strong></th>

<tr class="tableblock halign-left valign-top custom"><div class="content"><div class="paragraph"><p>John</p></div></div></td>

1 个答案:

答案 0 :(得分:0)

您应该为内联角色使用分隔符,以确保它们解析一致。例如:

| [.custom]*John*
| [.specific]`Woo`

分隔符影响生成的 HTML,因此第一个实例生成 <strong> 标记,第二个实例生成 <code> 块。虽然两者都有指定的类。

遗憾的是,该角色适用于文本内容,而不是 <th><td>。目前无法为单元格本身指定角色。

要实现您想要的演示,您必须使用基于表格类的 CSS 选择器。这需要向您的 Antora UI 添加自定义 CSS。也许是这样的:

table.custom th,table.custom td {
 /* appropriate styles */
}

解决方法

您应该为内联角色使用分隔符,以确保它们解析一致。例如:

| [.custom]*John*
| [.specific]`Woo`

分隔符影响生成的 HTML,因此第一个实例生成 <strong> 标记,第二个实例生成 <code> 块。虽然两者都有指定的类。

遗憾的是,该角色适用于文本内容,而不是 <th><td>。目前无法为单元格本身指定角色。

要实现您想要的演示,您必须使用基于表格类的 CSS 选择器。这需要向您的 Antora UI 添加自定义 CSS。也许是这样的:

table.custom th,table.custom td {
 /* appropriate styles */
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。