Need help with ToC's indentation [Hugo]
Hello, everyone! How can I reduce the indentation of Table of Content? It's for a personal blog with Hugo engine.
The primary goal is to move the indentation of the first level to align with ToC's title, while the second level is visibly indented. I want to keep using list just in case I need it in the future, so I'd like to avoid the option to turn it off (if it's even possible with just CSS).
What I'd like to achieve is something like this.
The default and what I tried to do (pics) are here:
https://imgur.com/a/ULYQTFb
What I tried to do (by following MDN docs):
1. Added
list-style: none. https://developer.mozilla.org/en-US/docs/Web/CSS/list-style
But it just hid the disc. The indentation is still there.
2. Added margin-left: -1.5em. https://developer.mozilla.org/en-US/docs/Web/CSS/margin
It's getting closer to what I want, but it also changed the indentation of the second level of ToC.
Thank you for your time and help. Pardon the newbie question.3 Replies
My guess is it's something to do with padding, but it's hard to tell without live code. Could you post a codepen that simulates the issue? It's more meaningful than screenshots.
Check the userstylesheet rules
By default a list has some left-padding
But yes posting the code would be better
Using the direct child selector
> would probably work.
This will remove the left margin on the initial ul element but not any nested ul elements that that might have: