org-mode 的表格导出为html,如何设置列宽?

jim*_*ing 8 html emacs org-mode

我使用 emacs org-mode 编写我的文档,并导出为 html。

对于表格,我想设置列宽(宽度的百分比),例如如下:

#+attr_html: :border 1 :rules all :frame border :width 100%
|----+-------------------------------------+-----------------|
| ID | BUG                                 | Result          |
|----+-------------------------------------+-----------------|
|  1 | jdkkskdjskdsdjsdljskdjfskfjksdjfksf | ok              |
|  2 | 823jjsljfdkjsdskkkkkuuffggg         | not bug         |
|  3 | aaaaahhaaaaa                        | can't reproduct |
|----+-------------------------------------+-----------------|
Run Code Online (Sandbox Code Playgroud)

当导出到html时,我想将3个标签(ID,BUG,结果)的宽度百分比设置为(2%,80%,18%)。

如何让它发挥作用?

Kal*_*ule 3

您可以通过在标题中插入 css 来做到这一点。(如果您想要更奇特,您还可以添加一个CSS-codeblock。)通过在表和 css 上放置一个类,您可以确保只有一个表受到 css 的影响。

这是您想要的表格(我还添加了一些背景颜色,因此很明显样式实际上已应用):

具有正确宽度的彩色列的表格

#+HTML_HEAD: <style type="text/css">
#+HTML_HEAD: .styledtable col:nth-of-type(1) { width:  2%; background: orange; }
#+HTML_HEAD: .styledtable col:nth-of-type(2) { width: 80%; background: dodgerblue; }
#+HTML_HEAD: .styledtable col:nth-of-type(3) { width: 18%; background: hotpink; }
#+HTML_HEAD: </style>

#+ATTR_HTML: :class styledtable
#+attr_html: :border 1 :rules all :frame border :width 100%
|----+-------------------------------------+-----------------|
| ID | BUG                                 | Result          |
|----+-------------------------------------+-----------------|
|  1 | jdkkskdjskdsdjsdljskdjfskfjksdjfksf | ok              |
|  2 | 823jjsljfdkjsdskkkkkuuffggg         | not bug         |
|  3 | aaaaahhaaaaa                        | can't reproduct |
|----+-------------------------------------+-----------------|
Run Code Online (Sandbox Code Playgroud)

有一个类似的问题类似的答案