【问题标题】:how can I add class attributes to table headers when exporting from org to html?从 org 导出到 html 时,如何将类属性添加到表头?
【发布时间】:2018-04-18 15:43:08
【问题描述】:

我想指定从 emacs Org-mode 文件导出到 html 的表中每一列的宽度。

实现这一点的具体方法是在生成的 html 中为每个 th 标签添加一个类属性。然后在我的 css 文件中按类指定列格式。参见例如,

https://css-tricks.com/fixing-tables-long-strings/

如何从 emacs Org-mode 生成类属性?

【问题讨论】:

    标签: html emacs org-mode


    【解决方案1】:

    我不知道直接在标题中添加属性的方法,但可以使用:nth-of-type(n) 选择器来设置它们的样式。

    #+OPTIONS: num:nil toc:nil html-postamble:nil ^:nil
    
    #+HTML_HEAD: <style type="text/css">
    #+HTML_HEAD: .styledtable { width: 400px;}
    #+HTML_HEAD: .styledtable col:nth-of-type(1) { width: 25%; background: yellow; }
    #+HTML_HEAD: .styledtable col:nth-of-type(2) { width: 50%; background: magenta; }
    #+HTML_HEAD: .styledtable col:nth-of-type(3) { width: 25%; background: cyan; }
    #+HTML_HEAD: </style>
    
    #+ATTR_HTML: :class styledtable
    | column1 | column2     | column3             |
    |---------+-------------+---------------------|
    | small   | medium text | very very long text |
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-26
      • 2021-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-12
      相关资源
      最近更新 更多