0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

obsidianのcssclassesでカスタムCSSのフォントを適用させる

Last updated at Posted at 2025-03-20

フロントマターのcssclassesに値を書くと .view-content 直下のdivにその名前でクラスが追加される

cssclasses変更したいやつを追加した結果:

image.png

<div class="
  markdown-source-view 
  cm-s-obsidian 
  mod-cm6 
  node-insert-event 
  is-live-preview 
  is-folding 
  show-properties 
  変更したいやつ"
  style="">

そして、ObsidianのVaultフォルダ/.obsidian/snippets に自作cssファイルを置いて設定から有効にしておくと、カスタムCSSを適用できる

image.png

なのでそれらを組み合わせると例えば歌詞のページはそれっぽくフォントを変えたり無限大にいろいろできるんだけど、なぜかfont-familyは適用されなくて困った。

CSS

最終的には以下のように書くと適用できた。
かなり雑なのでよろしくあれすること。

.変更したいやつ,
.変更したいやつ .cm-scroller {
    font-family: "HGP創英角ポップ体" !important;
    
    /* 適用できてるか分かりやすくするテスト */
    color: red;
    font-size: 30px;
}

image.png

Googleフォント

Googleフォントも使える

/* @import を先頭に書く */
@import url('https://fonts.googleapis.com/css2?family=Cherry+Bomb+One&display=swap');

.変更したいやつ,
.変更したいやつ .cm-scroller {
    font-family: "Cherry Bomb One" !important;
    
    /* 適用できてるか分かりやすくするテスト */
    color: orange;
    font-size: 30px;
}

image.png

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?