首页 > 解决方案 > emacs org 导出 HTML:自定义段落与列表边距

问题描述

遵循这个简单的解决方案,我使用margin-leftmargin-right以更易于阅读的格式获取导出的 HTML 页面,两边的边距更大:

#+HTML_HEAD_EXTRA: <style>*{margin-left: 2em}*{margin-right: 2em}</style>

所以页面看起来像:

        This is a very long sentence as an 
        example of reading friendly large
        margins in the exported HTML document
        of my org file.

代替:

This is a very long sentence as an example of not-reading friendly small margins
in the exported HTML document of my org file.

段落确实更好看。但是,现在的问题是增加的边距会影响 TOC 和正文中的所有列表项。像:

- List item 1
          - Subitem 1.1
          - Subitem 1.2
                   - Subsubitem 1.2.1
- List Item 2
          - Subitem 2.1
          - Subitem 2.2

我更愿意看到的地方:

- List item 1
  - Subitem 1.1
  - Subitem 1.2
    - Subsubitem 1.2.1
- List Item 2
  - Subitem 2.1
  - Subitem 2.2

现在,是否可以只为文本段落设置自定义边距,而不影响列表?什么是一个巧妙的方法呢?

标签: htmlemacsorg-mode

解决方案


你可以使用下面的CSS

#+HTML_HEAD_EXTRA:<style> *{margin-left: 2em;margin-right: 2em}    ul, ol, li, a {margin: 0;} </style>

或者

#+HTML_HEAD_EXTRA:<style> p{margin-left: 2em;margin-right: 2em} </style>

推荐阅读