[英]how can I add class attributes to table headers when exporting from org to html?
I would like to specify the width of each column in tables that are exported from an emacs Org-mode file to html.我想指定从 emacs Org-mode 文件导出到 html 的表中每列的宽度。
A specific way of achieving this would be to add a class attribute to each th
tag in the generated html.实现这一目标的具体方法是将一个类属性添加到每个
th
在生成的HTML标签。 And then specify the column formatting by class in my css file.然后在我的 css 文件中按类指定列格式。 See for example,
参见例如,
https://css-tricks.com/fixing-tables-long-strings/ https://css-tricks.com/fixing-tables-long-strings/
How can I generate class attributes from emacs Org-mode?如何从 emacs 组织模式生成类属性?
I don't know a way to add attribute the the header directly, but one could use the :nth-of-type(n)
selector to style them.我不知道一种直接在标题中添加属性的方法,但可以使用
: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 |
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.