如何在reStructuredText中定义csv表格的高度? [英] How to define the the height of the csv table in reStructuredText?

查看:67
本文介绍了如何在reStructuredText中定义csv表格的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码从 csv 创建一个表格,用于我在 readthedocs 中的文档:

I'm using this code to create a table from csv for my documentation in readthedocs:

.. csv-table:: Markram et al. Model & Network configuration file
   :file: ../config_files/Markram_config_file.csv
   :header-rows: 1

CSV 很大并且有很多行和列.对于列,一切都很好,因为它只适合页面中的几列,而其他列可以通过在表中滚动到右侧来访问.但是,所有行都放置在页面中,我无法为 csv 表格.我试图通过 :height: 100px 指定高度,但它没有为表格定义.无论如何要指定吗?这是我在表格中使用的示例.

The CSV is large and has a lot of rows and columns. For columns, everything is fine since it just fits a few columns in the page and the others can be accessed by scrolling to the right in the table. However, all of the rows are placed in the the page and I cannot specify a particular "length" or "height" for the csv table. I tried to specify the height by :height: 100px but it's not defined for the tables. Is there anyway to specify that? Here's a sample of what I'm using in the table.

推荐答案

紧接在 .. csv-table 指令之前,把它放在上面用一个空行分隔(见 https://stackoverflow.com/a/46195021/2214933):

Immediately before your .. csv-table directive, put this above with a blank line separating (see https://stackoverflow.com/a/46195021/2214933):

.. rst-class:: table-myclass

.. csv-table:: blah blah blah

以上将应用类名到呈现的 HTML 表.

The above will apply a class name to the rendered HTML table.

然后在您的 Sphinx 主题中添加自定义样式.假设您想限制每个表格行的高度(不是表格本身,因为 100 像素对于大量数据来说非常短),请输入以下内容:

Then in your Sphinx theme, add a custom style. Assuming you want to limit the height of each table row (not the table itself since 100px is pretty short for a lot of data) put the following:

table.myclass tbody tr {height: 100px;}

根据喜好调整 CSS 选择器和样式.

Adjust the CSS selector and style to taste.

请参阅如何在 Sphinx 中创建自定义样式.

这篇关于如何在reStructuredText中定义csv表格的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆