I’m having trouble writing CSS snippets that space headings the way I want. I have two different, but related issues, of not being able to get code to work in both editing and reading view.
I’ve managed to add extra spacing above headings in reading view:
/* Adds extra space above headings in reading view
h1 {
margin-top: 50px !important;}
h2, h3, h4, h5, h6 {
margin-top: 24px !important;
}
I’d like to add extra space above h1 in live editing mode, as well, because it will help visually differentiate different topics within a note, but the various CSS snippets I’ve tried haven’t done anything. This is what I’ve currently got:
.cm-header-1 {
margin-top: 20px !important;
}
It’s based off of this format, for adding underlines to headings in live preview mode:
.cm-header-4 {
text-decoration: underline !important;
text-underline-offset: 0.07em;
}
This works, so I don’t understand why the “margin-top” code doesn’t, seeing as this is the code that works for reading view.
The second problem is adding a horizontal line below folded headings. The code I have is this:
.is-collapsed > :is(h1, h2, h3, h4, h5, h6),
.HyperMD-header > .cm-fold-indicator.is-collapsed ~ .cm-widgetBuffer:last-of-type {
display: block !important;
content: "" !important;
padding-bottom: 20px !important;
border-bottom: 1px solid rgba(92, 70, 56, 0.30) !important;
}
This works for reading view, but not live editing view, despite the fact that the code that I modeled it off (which adds space below folded headings), works in both reading view and live editing mode:
/* Add space beneath folded headers - reader view, edit view */
.is-collapsed > :is(h1, h2, h3, h4, h5, h6),
.HyperMD-header > .cm-fold-indicator.is-collapsed ~ .cm-widgetBuffer:last-of-type {
margin-bottom: 24px !important;
}
I’ve tried rewriting it to refer to editing view headings:
.is-collapsed > :is(cm-header-1, .cm-header-2, .cm-header-3, .cm-header-4, .cm-header-5, .cm-header-6),
.cm-header > .cm-fold-indicator.is-collapsed ~ .cm-widgetBuffer:last-of-type {
display: block !important;
content: "" !important;
padding-bottom: 20px !important;
border-bottom: 1px solid rgba(92, 70, 56, 0.30) !important;
}
But this doesn’t work.
If someone could help me fix these, I’d really appreciate it.
