5

Anki卡片共享CSS的方法

 2 years ago
source link: https://www.lujun9972.win/blog/2021/05/24/anki%E5%8D%A1%E7%89%87%E5%85%B1%E4%BA%ABcss%E7%9A%84%E6%96%B9%E6%B3%95/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Anki卡片共享CSS的方法

Anki 允许为不同的卡片类型设置不同的CSS样式,但有时我们会希望在多个卡片类型之间共享同一份样式以保证卡片展示的一致性。 由于 collection.media 目录中的文件所有卡片都能访问,因此可以将该目录作为中转中心实现卡片间共享CSS的目的。

  1. 将 CSS 文件放在 collection.media 目录中

    Windows下该目录所在路径为 %appdata%\Anki2\用户\collection.media\

    Linux下该目录所在路径为 ~/.local/share/Anki2/用户/collection.media

    MAC下该目录路径为 ~/Library/Application Support/Anki2/用户/collection.media

  2. 为了防止 CSS 文件在 检查媒体 时被作为无用媒体文件删除,CSS 文件需以下划线(_)开头。

    cat _anki_base.css
    
    .extra{
        margin-top:15px;
        font-size:16px;
        color: black;
        text-align:left;
    }
    
  3. 编辑卡片样式,在样式中通过 @import url("_anki_base.css"); 引入共享的CSS文件。

share_css_in_anki.png


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK