Skip to content

Instantly share code, notes, and snippets.

@charliecm
Created August 13, 2021 04:33
Show Gist options
  • Save charliecm/587320ae0b9b7354f87f7e57728d03cb to your computer and use it in GitHub Desktop.
Save charliecm/587320ae0b9b7354f87f7e57728d03cb to your computer and use it in GitHub Desktop.
Obsidian custom CSS snippets.
/* ROOT -------------------------------------------------------------------- */
:root {
--default-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Microsoft YaHei Light", sans-serif;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 700;
}
/* EDITOR ------------------------------------------------------------------ */
/* Titlebar: Hide it and make window frameless */
.titlebar-button-container {
display: none;
}
.titlebar,
.titlebar-inner {
height: 26px !important;
}
.titlebar {
background: var(--background-secondary-alt);
}
.titlebar-text {
top: 2px;
color: black;
}
.is-frameless .horizontal-main-container {
background: var(--background-secondary-alt);
padding-top: 4px;
}
.is-frameless .view-content {
height: calc(100% - 30px);
}
/* Status bar: Hide it */
.status-bar {
display: none;
}
/* View header: Clean up */
.is-frameless .workspace-split.mod-root > .workspace-leaf:last-of-type .workspace-leaf-content {
border-top-right-radius: 0;
}
.is-frameless .workspace-split.mod-root > .workspace-leaf:first-of-type .workspace-leaf-content {
border-top-left-radius: 0;
}
.is-frameless .view-header {
height: 30px;
border-top: 0;
border-bottom: 0 !important;
}
.is-frameless .view-header-icon {
padding: 6px 6px;
top: 0;
}
.is-frameless .view-header-title {
line-height: 31px;
font-size: 14px;
}
.is-frameless .view-header-title-container {
height: 30px;
line-height: 30px;
padding-left: 0;
}
.is-frameless .view-actions {
padding: 2px 10px;
}
.is-frameless .workspace-split.mod-root {
background-color: transparent;
}
/* SOURCE ------------------------------------------------------------------ */
:root {
--font-monospace: "JetBrains Mono", Menlo, monospace;
}
.cm-s-obsidian, .cm-s-obsidian * {
font-size: 0.875rem !important;
line-height: 1.5rem !important;
-webkit-font-smoothing: auto;
}
.is-frameless .cm-s-obsidian * {
font-size: 1rem !important;
line-height: 2rem !important;
}
.cm-s-obsidian .cm-header, .cm-s-obsidian .cm-strong {
font-weight: 800;
}
.cm-s-obsidian .cm-hmd-frontmatter,
.cm-s-obsidian .HyperMD-codeblock *,
.cm-s-obsidian .HyperMD-table-row,
.cm-s-obsidian .HyperMD-table-row * {
font-size: 0.875rem !important;
line-height: 1.5rem !important;
}
/* Fold: Fix position */
.CodeMirror-gutter-elt {
top: -5px;
}
/* Code: Normalize */
.cm-s-obsidian span.cm-inline-code,
.cm-s-obsidian pre.HyperMD-codeblock {
font-size: 1em;
}
.cm-s-obsidian span.cm-inline-code,
.cm-s-obsidian span.cm-inline-code:not(.cm-formatting):not(.cm-hmd-indented-code):not(.obsidian-search-match-highlight) {
background-color: var(--background-code);
}
/* Footnote: Remove left spacing */
.cm-s-obsidian .HyperMD-footnote {
padding-left: 5px;
text-indent: 0;
}
/* Footnote: Align with baseline */
.cm-s-obsidian span.cm-footref, .cm-s-obsidian span.cm-blockid {
vertical-align: baseline;
}
/* List: Remove top spacing */
.cm-s-obsidian .HyperMD-list-line {
padding-top: 0;
}
/* Table code: Fix font */
.cm-s-obsidian .HyperMD-table-row span.cm-inline-code {
font-size: inherit !important;
}
/* PREVIEW ----------------------------------------------------------------- */
.markdown-preview-view {
font-size: 0.875rem;
line-height: 1.5;
}
.is-frameless .markdown-preview-view {
font-size: 1rem;
}
.markdown-preview-view hr {
border-width: 1px;
}
.markdown-preview-view strong {
font-weight: 700;
}
/* Paragraphs */
.markdown-preview-view p {
margin-block-start: 0;
margin-block-end: 1em;
}
.markdown-preview-view li p:last-of-type {
margin-block-end: 0;
}
/* Headings */
.markdown-preview-view h1 {
margin-top: 0.75em;
margin-bottom: 1.5rem;
font-size: 2em;
line-height: 1.25em;
}
.markdown-preview-view h2 {
margin-top: 1.125em;
margin-bottom: 0.75em;
font-size: 1.3333em;
line-height: 1.3333em;
}
.markdown-preview-view h3 {
margin-top: 1.5em;
margin-bottom: 1em;
font-size: 1em;
}
/* List */
.markdown-preview-view ul li,
.markdown-preview-view ol li {
padding-left: 0.375em;
margin-bottom: 0.375em;
}
.markdown-preview-view ul li:first-of-type,
.markdown-preview-view ol li:first-of-type {
margin-top: 0.375em;
}
.markdown-preview-view blockquote {
margin-inline-start: 0;
margin-inline-end: 0;
border-radius: 4px;
border-left-width: 0.375em;
padding: 0.75em 1.25em 0.75em 0.875em;
}
/* Footnote: Make header footnotes smaller */
.markdown-preview-view h1 .footnote-ref,
.markdown-preview-view h2 .footnote-ref,
.markdown-preview-view h3 .footnote-ref {
font-size: 0.75em;
}
/* Folding: Make them only appear on hover */
.markdown-preview-view .collapse-indicator {
opacity: 0;
line-height: 1.375em;
}
.markdown-preview-view h1 .collapse-indicator {
line-height: 1.125em;
}
.markdown-preview-view h2 .collapse-indicator {
line-height: 1.125em;
}
.markdown-preview-view .heading-collapse-indicator {
position: absolute;
padding-left: 6px;
padding-right: 44px;
}
.is-frameless .markdown-preview-view .heading-collapse-indicator {
padding-left: 14px;
}
.markdown-preview-view .list-collapse-indicator {
position: absolute;
margin-left: -48px;
padding-right: 24px;
line-height: 1.25em;
}
.markdown-preview-view .is-collapsed .collapse-indicator,
.markdown-preview-view li:hover .collapse-indicator,
.markdown-preview-view h1:hover .collapse-indicator,
.markdown-preview-view h2:hover .collapse-indicator,
.markdown-preview-view h3:hover .collapse-indicator {
opacity: 1;
}
/* Table */
.markdown-preview-view table, .table-view-table {
font-size: 0.875em !important;
}
.markdown-preview-view td, .markdown-preview-view th {
border: 0;
}
.markdown-preview-view th, .table-view-table > thead > tr > th {
font-size: 0.875em !important;
font-weight: 600 !important;
border-bottom: solid 2px var(--text-normal) !important;
}
.markdown-preview-view tr, .table-view-table > tbody > tr {
border-bottom: 1px solid var(--table-line);
}
.markdown-preview-view th, .markdown-preview-view td {
text-align: left;
vertical-align: top;
}
/* Code */
.markdown-preview-view pre {
overflow-x: auto;
}
.HyperMD-table-row span.cm-inline-code, pre > code:not(.prism) {
font-size: 0.875em !important;
}
.theme-light .token.operator {
background-color: transparent;
}
/* Theme */
.theme-light {
--table-line: #ddd;
--text-highlight-bg: rgba(255,228,0,0.3);
--text-accent: #0d6efd;
--text-accent-hover: #084298;
}
.theme-dark {
--table-line: #666;
--text-highlight-bg: rgba(255,228,0,0.2);
--text-accent: #64b5f6;
--text-accent-hover: #2196f3;
}
/* Kanban: Mobile title height fix */
.kanban-plugin__markdown-preview-view.kanban-plugin__lane-title-text {
display: block;
padding: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment