As a CSS newbie I have to frequently ask fellow Obsidianites what code to use to achieve a certain effect in my custom CSS sheet.
I have made a habit of collecting these habits, and, to make them more easily searchable, I transferred them to …… you guessed it: an MD file.
I thought it might be useful to share this with others, who can then add their own snippets, which I can add to the file.
I have categorized the snippets on the basis of what they are used for, and have added # headers.
You can scan the headers in the Outliner pane to find a relevant snippet. People not interested in learning CSS or wanting a shortcut to implement certain thing can use these snippets too.
Note 1: the snippets are supplied as they are, and as I am not a CSS expert I cannot assist in fixing errors that might occur if e.g. there are clashes with other parts of your CSS.
Note 2: there is now a plug-in that you can use to manage individual code snippets. The plug-in, called “css snippets” (duhhh) was made by Daniel Brandenburg; he has an interesting road map for future development. Update: the plug-in is now integrated in Obsidian core.
You can view or download the CSS code on Github.
If there’s an interesting piece of code you think is missing you made add it with a pull request in the Github repository (provided you have a Github account), or post it here and I’ll add it.