@DitchComfort try this:
for Edit mode:
.cm-link, .cm-s-obsidian span.cm-url {
font-style: italic;
}
and for Reading (= Preview) mode:
a.external-link {
font-style: italic;
}
@DitchComfort try this:
for Edit mode:
.cm-link, .cm-s-obsidian span.cm-url {
font-style: italic;
}
and for Reading (= Preview) mode:
a.external-link {
font-style: italic;
}
Thank you!
Simple CSS snippet to change the background color for the preview popup.
.markdown-embed {
background-color: DarkSlateGray;
}
Iām really excited about this one, hoping others will enjoy it too!
That is really pretty. Excellent work! Thanks.
@zremboldt this will undoubtedly make some people happy. Is there a possibility to make it render in Live Preview too?
Hey all, need a little help here, I would like to have the font reduce in size according to indentation level (so the more indented a bullet point is, the smaller the text becomes). If anyone here with better CSS skills feels like giving it a go I would very much appreciate it!
@Iv3llios : I have no idea how to do this, but maybe someone else will reply. In case you are not aware of it, I just want to say that if you get any answers, or not satisfactory one, try the #appearance
channel on Obsidian Discord. There are some amazing CSS wizards there.
@Klaas Thanks for the tip, ill head there if I canāt find a solution! Cheers!
Hi @Iv3llios,
I would like to have the font reduce in size according to indentation level (so the more indented a bullet point is, the smaller the text becomes).
For Live Edit mode:
You can change the size of the text on the indent by changing this:
.cm-s-obsidian .HyperMD-list-line-1 {
font-size: 1em;
}
You need to do that for each level though, in other words you will need multiple entries with the number 1 changed to the level number.
.cm-s-obsidian .HyperMD-list-line-1 { font-size: 1em; }
.cm-s-obsidian .HyperMD-list-line-2 { font-size: .9em; }
.cm-s-obsidian .HyperMD-list-line-3 { font-size: .8em; }
.cm-s-obsidian .HyperMD-list-line-4 { font-size: .7em; }
If you go say 4 levels deep the 5th level will start the size selections all over again, so level 5 will be the size of level 1, level 6 will be the size of level 2, etc.
You can also change the color of the text as well, I feel that makes the list easier for me to brows through quickly.
For Read view:
I have only been able to find out how to change all the lines under the 1st line, not each individual one. They do scale down for each level but I canāt control how much.
div ul > li {
font-size: 1em;
}
/* all other level items of the list */
div ul ul > li {
font-size: .95em;
}
Below is the CSS for and screenshots of how mine currently look. If you have found a better way please let me know. If anyone has any suggestions to do better or clean it up some I would appreciate it.
Here is what my lists look like in Live Edit:
Here is what they look like in Reading:
Here is the CSS to get that gives me that:
/* Lists
alltagsverstand https://forum.obsidian.md/t/css-code-to-change-color-and-size-of-bullet-points/15230/7
entropic https://forum.obsidian.md/t/custom-colors-for-lists-symbols-and-or-text-editor-only/11185
*/
/* Lists - text color for both ul and ol in Edit view */
.cm-s-obsidian .HyperMD-list-line-1 {
font-family: var(--font-family-editor);
font-size: 1em;
color: var(--TextColorBodyEditor);
}
.cm-s-obsidian .HyperMD-list-line-2 {
color: #acb19899;
font-size: 1.em;
}
.cm-s-obsidian .HyperMD-list-line-3 {
color: #acb19888;
font-size: .95em;
}
.cm-s-obsidian .HyperMD-list-line-4 {
color: #acb19877;
font-size: .9em;
}
.cm-s-obsidian .HyperMD-list-line-5 {
color: #acb19877;
font-size: .9em;
}
.cm-s-obsidian .HyperMD-list-line-5 {
color: #acb19877;
font-size: .9em;
}
.cm-s-obsidian .HyperMD-list-line-6 {
color: #acb19877;
font-size: .9em;
}
/* Lists - Unordered list dots Edit view */
.cm-formatting.cm-formatting-list.cm-formatting-list-ul.cm-list-1 { color: yellow !important;}
.cm-formatting.cm-formatting-list.cm-formatting-list-ul.cm-list-2 { color: #FDB777 !important;}
.cm-formatting.cm-formatting-list.cm-formatting-list-ul.cm-list-3 { color: #FDA766 !important;}
.HyperMD-list-line.HyperMD-list-line-4 .cm-formatting-list-ul.cm-list-1 { color: #FD9346 !important;}
.HyperMD-list-line.HyperMD-list-line-5 .cm-formatting-list-ul.cm-list-2 { color: #FD7F2C !important;}
.HyperMD-list-line.HyperMD-list-line-6 .cm-formatting-list-ul.cm-list-3 { color: #FF6200 !important;}
/* Lists - Ordered list dots Edit view */
.cm-formatting.cm-formatting-list.cm-formatting-list-ol.cm-list-1 { color: yellow !important;}
.cm-formatting.cm-formatting-list.cm-formatting-list-ol.cm-list-2 { color: #FDB777 !important;}
.cm-formatting.cm-formatting-list.cm-formatting-list-ol.cm-list-3 { color: #FDA766 !important;}
.HyperMD-list-line.HyperMD-list-line-4.CodeMirror-line .cm-formatting-list-ol.cm-list-1 { color: #FD9346 !important;}
.HyperMD-list-line.HyperMD-list-line-5.CodeMirror-line .cm-formatting-list-ol.cm-list-2 { color: #FD7F2C !important;}
.HyperMD-list-line.HyperMD-list-line-6.CodeMirror-line .cm-formatting-list-ol.cm-list-3 { color: #FF6200 !important;}
/* Lists - Padding in Edit view */
.cm-s-obsidian .HyperMD-list-line {
padding-top: 0.1em;
min-height: 1.5em;
/* Defaults from app.css v0.3.19
.cm-s-obsidian .HyperMD-list-line {
padding-top: 0.3em;
min-height: 1.5em;
}*/
}
/* Lists - text color for both ul and ol in Reading view */
/* **first** level items of a list */
div ul > li {
color: var(--TextColorBodyEditor);
font-size: 1em;
}
/* all other level items of the list */
div ul ul > li {
color: #acb19899;
font-size: .95em;
}
Change colour of external links and highlight not-existing notes
I only found out about CSS recently and this feature makes my notes much tidier, love it! Thanks @Klaas for this collection.
The instructions to add a CSS snipet.
However, some of it doesnāt work completly as I would wish:
.cm-s-obsidian span.cm-hmd-internal-link {
color: #6d7df2;
}
.cm-s-obsidian span.is-unresolved {
color: #e44949;
opacity: 1 !important;
}
.is-unresolved::after {
content: "ā ";
}
.cm-s-obsidian span.cm-link {
color: #81f26d;
}
@GatoStruck to get it to work in Reading mode, use
.markdown-preview-view
Thanks for this and the Github files. Iāve learned heaps.
Is there any notation/documentation/place for css snippets that are for use with the new LivePreview editor? For example: āthis css works with LivePreview editor.ā āThis is for legacy editor (pre-LivePreview), use this syntax now.ā Iāve seen individual posts explaining the changes but itās always hard to tell what is the current agreed upon syntax vs old.
I had a bunch of css snippets stop working with the switch to LivePreview, but I think Iāve got everything mostly sorted out now.
Anyway, thanks again.
@ariehen thanks for your kind words. I donāt think there is documentation showing what is for the āoldā Edit mode (= CM5) and for Live Preview (= CM6). It is a bit āhit and missā, as you have experienced and as I have experienced myself. The misses youāll have to fix, and 1 good source of support is the #appearance
channel on Discord, where there are some people with amazing expertise in this.
Hit and miss is right. My personal .md file of obsidian css hacks needs a cleaning.
On a positive note, as time goes by we can (hopefully) assume posted css tips work with Live Preview.
Thanks again.
Iām adding a custom cssclass to achieve per note styling. This works fine, but how do I target dark or light themes (still in a āper noteā context)? TIA
Current example code (CSS snippet), which I then activate using cssclass: school
.school {
font-size: 0.90em;
}
@govsat1 I have no idea. Your best bet is to ask in the #appearance
channel on Discord, there are some amazing css gurus.
@govsat1 - If your intention is to have them different for dark mode than in light mode, you need to use css variables.
Define the variables for each mode class first, then use them in the css class you want to put in the file.
Something like this:
/* light mode styles */
.theme-light {
--text-color-school: blue;
--font-size-school: 0.8rem;
}
.theme-dark {
--text-color-school: red;
--font-size-school: 1.2rem;
}
.school {
color: var(--text-color-school);
font-size: var(--font-size-school);
}
This will make your cssclass: school
have a different style for dark and light modes when added to a specific note.
If your intention is to have them the same for both modes, you donāt need to set anything for the modes, it will just work in both.
.school {
color: red;
font-size: 0.8rem;
}
Hope that helps!
Dataview somewhat recently added a results count in tables and task lists that is nearly invisible for me on the default dark mode in Obsidian. Hereās a quick snippet that made it more visible in dark mode, but you could set anything. (Selector source: dataview developer in a GitHub discussion).
I am new to CSS but I think the !important
is necessary here because the plugin snippet is the same level of specificity, also sets color
and seems to be winning the tie-breaker - maybe it is included after the user snippet?
.dataview.small-text {
color: var(--text-accent) !important;
}
Youāll probably have to close and re-open Obsidian to see the results, or otherwise cause your dataview to re-render.
If anyone has other suggestions for what to put in this snippet, Iād love to learn more CSS.
Iām pretty sure @Klaas or @kepano asked for this like 14 months ago. Iāve just been prioritizing other things in life since then or just plain forgot. So thanks everyone for your patience.
Here is a link:
Grid mode will not work in live preview mode due to the extra HTML elements added by obsidian. Works well in reading mode still.
Iāve noticed some odd behaviour when using the cursor to select text in ālive previewā mode. It will work fine if you are going left/right but will have some odd skipping when going up/down line by line.
Images with the ā+tapeā and ā+pinā flags need to be included in a paragraph with the text that goes next to it. Otherwise the āDIVā element which contains them wonāt be large enough.
Compare the following two examples. Both have edit mode on the left with live preview engaged. Reading view is on the right.
The first one has the image in its own paragraph which causes clipping of the tape element:
The second puts the image in the same paragraph as the text which resolves the issue. In both cases, the reading view is unaffected.
Here is an updated list of all the flags currently in use:
+side
+tape
+pin
+portrait
+landscape
+banner
+hr
-left
-right
-thumb
-sm
-med
-lg
-huge
-full
-border1
-border2
-border3
-bround1
-bround2
-TLround
-TRround
-BLround
-BRround
-bthick
-bthin
-shadow
-glow
-glow2