通过Markdown设置表格列宽 [英] Set table column width via Markdown

查看:411
本文介绍了通过Markdown设置表格列宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Slate 的项目,该项目允许使用以下格式的表标记.

I have a project using Slate, which allows using table markup in the following format.

Name | Value
-------|-------------------
`Value-One` | Long explanation
`Value-Two` | Long explanation
`etc` | Long explanation

我的问题是第一列太窄了,并且包装了内容(即将代码值分成两行),而不是将其显示在一行上.我的偏好是第一列的宽度足以显示名称/键,然后第二列可以占用其余的可用空间.

My problem is that the first column is rendered too narrow, and is wrapping the content (i.e. breaking the code values onto two lines) rather than displaying it on a single line. My preference is that the first column be wide enough to display the name/key fully, and then the second column can take up the rest of the available space.

我的问题是是否有可能(因此,如何)通过标记设置列宽,或者至少通过标记将类添加到表中(以便我可以通过CSS设置特定表的样式).还是有更好的方法呢?我不想不必用完整的HTML来写表(这是不得已的选择).

My question is if it is possible (and therefore, how) to set the column width via markup, or at least add a class to the table via markup (so that I can style a particular table via CSS). Or is there a better approach to this? I'd prefer not to have to write out the table in full HTML (which would be a last resort option).

推荐答案

我不确定这是否适合您的情况.

I'm not sure if this works in your case.

您可以尝试将表格包装到div中,然后通过CSS设置样式:

You can try wrapping the table into a div and then style it via CSS:

<div class="foo">

Header | header
------ | -----
Bar | bar

</div>

CSS:

.foo table {
  styles...
}

应该工作.

希望能有所帮助!

这篇关于通过Markdown设置表格列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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