Reduce space between headers and body text #7366
-
A couple small questions.
Without having to do it on every page, or write all headers in html. I am having trouble understanding the partials and blocks. When I added: custom_dir: overrides, even if there was no main.html or toc.html, it made both navigation on left side and toc on right disappear. I thought I got Giscus commenting to do something, but maybe I have to check after pushing to Github, because on mkdocs serve it gives me a small window of my website at the bottom. I tried adding some random things in extra.css that I used for my custom color theme but they didn't do anything.
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hello @jonsnow231,
I'm not sure why you separate between Markdown and HTML headings 🤔 MkDocs processes the Markdown and this gets turned into HTML, and the web browser uses CSS to style HTML, not Markdown. You can use the browser web developer tools to see what is taking up space for a given element. In the example below the H3 tag we can see it has both margin-top and margin-bottom. You can modify the extra CSS for a single tag, or use the
Vertical margin auto collapses, so if 2 adjacent elements have margin on the same side it will only behave as it was 1 margin (the bigger of the 2 if applicable).
No, there is not, as seen in the templates the value for the hidden sidebar is taken directly from the mkdocs-material/src/templates/base.html Lines 316 to 326 in 4f8081c Overriding
The entry point for every generated page is the mkdocs-material/src/templates/base.html Lines 89 to 98 in 4f8081c If you override it in your As for partials the program holds an internal mapping of available template files for example mkdocs-material/src/templates/base.html Lines 153 to 154 in 4f8081c By default it will look for that Simply put, follow the thread of execution from top to bottom, starting from As for the |
Beta Was this translation helpful? Give feedback.
-
If you add the html rather than markdown headers, they don't show up in the ToC. I saw it in these discussions somewhere. Actually, while I was trying to find it again, I stumbled on one way to hide the ToC globally: #478 (comment)
But I have no idea how to add those blocks/snippets still. I tried following the customization to add something like:
Even trying to put it in main.html, content.html, extra.css, and splitting up the .md in extra.css and the other in the other two, but I couldn't figure it out. It made no changes at all, just like the .md-nav--secondary. So I couldn't try to figure out specificity with the inspect tool, because there were no changes to it at all. The extra.css is working for my custom theme where I just changed colors, but nothing else. |
Beta Was this translation helpful? Give feedback.
-
So then if I wanted to add this css:
What would be the correct place to add it in a new mkdocs folder? It sounds like I am just not putting it in correctly. |
Beta Was this translation helpful? Give feedback.
https://squidfunk.github.io/mkdocs-material/customization/#additional-css
Inside the extra.css file just like the colors.