LoginSignup
3
2

More than 3 years have passed since last update.

Makrdownの表内フォントサイズを変更する方法

Last updated at Posted at 2020-03-15

Markdownで、表内のフォントサイズを変更する方法を調べたので備忘録として。

<style>
table, th, td {
    font-size: 50%;
}
</style>

とかMarkdownファイル内に書いておけばフォントサイズは変わるのであるが、
これだけだと、Markdown内の全部の表に適用されてしまう。
個別適用したいこともあるかもしれないので、その場合は子要素セレクタを使って以下のようにする。

<style>
.smalltable > table, .smalltable > th, .smalltable > td {
    font-size: 50%;
}
</style>

上記は、smalltable というクラスの子要素になっている table ではフォントサイズを 50% にするっていう意味。

試しに以下のように記述する

Tableのフォントサイズ変更のサンプル

<style>
.smalltable > table, .smalltable > th, .smalltable > td {
   font-size: 50%;
}
</style>

<div class="smalltable"> 

表1
|  TH  |  TH  |
| ---- | ---- |
|  TD  |  TD  |
|  TD  |  TD  |

</div>

表2
|  TH  |  TH  |
| ---- | ---- |
|  TD  |  TD  |
|  TD  |  TD  |

Tableのフォントサイズ変更のサンプル

VSCodeのプレビューでは反映されたけど、Qiita, Githubだと効いてない...

一応VSCodeでのキャプチャ
markdownで表のフォントサイズ変更.png

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2