CollectionBuilder 公式ドキュメント(英語)の非公式の日本語訳です。訳と、日本語・CJK の資料向けに足した節の責任は訳者(中村 覚、東京大学)にあります。内容が食い違うときは英語の原文が正です。
カスタム CSS の追加
組み込みの theme.yml やテーマカラーの設定のオプションを超えて、CollectionBuilder のテンプレートでは、サイト上の他のすべてのスタイルを上書きするカスタム CSS を追加できるようになっています。
独自のカスタム CSS/SCSS は “_sass/_custom.scss” ファイルに追加します。これにより、ご自身のスタイルが CollectionBuilder や Bootstrap の既定のスタイルを確実に上書きするようになります。
“_sass/” フォルダには、テンプレートの「Sass パーシャル」、つまり Sass CSS をモジュール化した部品が入っています。 Jekyll がサイトをビルドするとき、これらのパーシャルは “assets/css/cb.scss” ファイルに読み込まれ、標準的な CSS ファイルに変換されます。 生成された “cb.css” ファイルは、すべてのページの head 内で最後に読み込まれるスタイルシートとなるため、そこに含まれるスタイルは Bootstrap や他のライブラリの CSS を上書きします。
通常は、”cb.scss” や他のパーシャルは編集しないでください。 代わりに、”_sass/_custom.scss” を使って、既存のテンプレートのスタイルを上書きしたり、新しいスタイルを追加したりします。
“_sass/_custom.scss” を使うことで、カスタマイズ内容をテンプレート本体と分けて管理できるため、更新しやすくなり、他のすべてのスタイルを確実に上書きできます。
Bootstrap のルートクラスを使う
Bootstrap では一部のスタイル機能が CSS カスタムプロパティとして公開されているため、既定値を上書きしてテーマを微調整できます。 以下は、テーマをカスタマイズするために “_sass/_custom.scss” に追加できるクラスの例です。
/* root variable overrides */
:root, [data-bs-theme="light"] {
/* ----- Border radius -----
Most components (buttons, cards, inputs, alerts, modals) inherit from --bs-border-radius.
Try 0 for a sharp editorial look, or 1rem+ for a soft rounded look. */
--bs-border-radius: 0.375rem;
--bs-border-radius-sm: 0.25rem;
--bs-border-radius-lg: 0.5rem;
--bs-border-radius-xl: 1rem;
--bs-border-radius-xxl: 2rem;
--bs-border-radius-pill: 50rem;
/* ----- Body background, text, and headings ----- */
--bs-body-bg: #fff;
--bs-body-color: #212529;
--bs-heading-color: #1a2e40;
/* ----- Links -----
Set both the hex value and the -rgb channels (used by utilities like .link-opacity-*). Keep them in sync. */
--bs-link-color: #0d6efd;
--bs-link-color-rgb: 13, 110, 253;
--bs-link-hover-color: #0a58ca;
--bs-link-hover-color-rgb: 10, 88, 202;
--bs-link-decoration: underline;
/* ----- Borders and dividers ----- */
--bs-border-color: #dee2e6;
--bs-border-width: 1px;
/* ----- Theme color utilities -----
These -rgb channels drive .bg-primary, .text-primary, .border-primary, .text-bg-primary, etc.
(Buttons are separate) */
--bs-primary-rgb: 13, 110, 253;
--bs-secondary-rgb: 108, 117, 125;
--bs-success-rgb: 25, 135, 84;
--bs-danger-rgb: 220, 53, 69;
--bs-warning-rgb: 255, 193, 7;
--bs-info-rgb: 13, 202, 240;
--bs-light-rgb: 248, 249, 250;
--bs-dark-rgb: 33, 37, 41;
/* ----- Subtle background/border tiers -----
Used by .bg-body-secondary, card caps, list group actions, etc. */
--bs-secondary-bg: #e9ecef;
--bs-tertiary-bg: #f8f9fa;
--bs-secondary-color: rgba(33, 37, 41, 0.75);
/* ----- Typography -----
Alternative to using "_data/theme.yml" (base-font-family, base-font-size) if you are loading a font via font-cdn */
--bs-body-font-family: Georgia, "Times New Roman", serif;
--bs-body-font-size: 1rem;
--bs-body-font-weight: 400;
--bs-body-line-height: 1.5;
}
/* component level override examples */
/* Buttons example */
.btn-primary {
--bs-btn-bg: #33638e;
--bs-btn-border-color: #33638e;
--bs-btn-hover-bg: #2a527a;
--bs-btn-hover-border-color: #2a527a;
--bs-btn-active-bg: #24466a;
--bs-btn-active-border-color: #24466a;
--bs-btn-disabled-bg: #33638e;
--bs-btn-disabled-border-color: #33638e;
}
/* Cards */
.card {
--bs-card-border-color: transparent;
--bs-card-box-shadow: var(--bs-box-shadow-sm);
box-shadow: var(--bs-card-box-shadow);
}
/* Navbar (colors are usually set in _data/theme.yml navbar-background / navbar-color, but spacing/behavior tweaks can go here):
.navbar {
--bs-navbar-padding-y: 0.75rem;
--bs-navbar-brand-font-size: 1.5rem;
}