簡體   English   中英

如何更改 markdown 中表格的填充?

[英]How to change padding of a table within markdown?

我正在使用 Jekyll Spaceship 構建表格,並且對單行占用的空間不滿意。 我的表格非常簡單,我在 markdown 文件中有。

|              Stage | Direct Products | ATP Yields |
| -----------------: | --------------: | ---------: |
|         Glycolysis |          2 ATP              ||
| Pyruvaye oxidation |          2 NADH |      5 ATP |
|  Citric acid cycle |          2 ATP              ||
|                               30--32 ATP        |||

我的問題是文本甚至不占單元格空間的一半,文本上方和下方都有填充。

如何減少 markdown 文件中表中行的填充?

我還嘗試添加以下內容...

<style>
table, th, td {
    padding: 1px;
}
</style>

<div class="bettertd">

| .... placed markdown tables here ... |

</div> 

這把它放在 CSS...

.features table {
    styles="padding:1px";
}

但是沒有用。

首先,您可以為下表指定 class:

|              Stage | Direct Products | ATP Yields |
| -----------------: | --------------: | ---------: |
|         Glycolysis |          2 ATP              ||
| Pyruvaye oxidation |          2 NADH |      5 ATP |
|  Citric acid cycle |          2 ATP              ||
|                               30--32 ATP        |||
{:.custom-table}

And Second step, you need to add your custom css styles to the your jekyll theme css file (usually under the _sass folder and named *.sass ).

//...

.custom-table th, .custom-table td {
   padding: 1px;
   // any style you want ...
}

或者添加到主題帖子布局的頭部(通常在_layout文件夾下並稱為*.html )。

<html>
  <head>
    <!-- ... -->
    <style>
      .custom-table th, .custom-table td {
        padding: 1px;
        // any style you want ...
      }
    </style>
  </head>
  <body>
    ...
  </body>
<html>

甚至你使用jekyll-spaceshipelement-processor來修改元素樣式( 點擊查看更多使用細節),將配置添加到你的_config.yml如下:

jekyll-spaceship:
  element-processor:
    css:
      - [.custom-table th, .custom-table td]:  # Select the th, td nodes of custom table
          props:                               # Replace element properties
            style:                             # Add style attributes (Hash Style)
              padding: 1px                     # Add padding 
              # font-size: '1.2em'             # Add any style that you want

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM