欢迎访问我的独立博客

markdown 表格宽度调整

先在浏览器中看看 HTML是怎样的:
<table> <thead> <tr> <th>名称</th> <th></th> <th>备注</th> </tr> </thead> <tbody> <!-- 省略 tbody 内容 --> </tbody> </table>
利用浏览器上的开发者工具我们可以调试一下,把【名称】左边的 <th> 改为:
<th style="width: 100px;">
  • 1
  看起来似乎不错。回到 Markdown 上,在原表格前添加 CSS 代码,类似这样:
<style> table th:first-of-type { width: 100px; } </style> <!-- 下方是表格的 Markdown 语法 --!>
首先 <th> 存在于 <table> 中;其次 th:first-of-type 的意思是每个 <th> 为其父级的第一个元素,这里指的就是围绕着【名称】的 <th>。同理第二、三个使用 th:nth-of-type(2)th:nth-of-type(3) 就可以了,以此类推。 
  上述的 th:first-of-type 等于 th:nth-of-type(1)
posted @ 2018-05-09 19:49  github.com/starRTC  阅读(7691)  评论(0编辑  收藏  举报