Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better alignment for current selected menu item in readthedocs theme #888

Merged
merged 3 commits into from
Aug 16, 2016

Conversation

styfle
Copy link
Contributor

@styfle styfle commented Apr 8, 2016

It's hard to explain why the alignment looks bad so I will show you a before and after screenshots.

Nothing selected

This looks fine and will remain the same 👍

first

Select a menu item

This looks wrong because the sub-menu item moved to the left after being clicked 😮

second

My Fix

Here we can see that the menu item is properly aligned when it is selected 🎉

third

It's hard to explain why the alignment looks bad so I will show you a before and after screenshots.
This is only a bug for subnav (nav inside nav) so only apply fix to subnavs.
@d0ugal
Copy link
Member

d0ugal commented Apr 24, 2016

This looks good, I'd like to see it have some further testing by more people and more browsers.

@d0ugal d0ugal added this to the 0.16 milestone Apr 24, 2016
@styfle
Copy link
Contributor Author

styfle commented Apr 24, 2016

Ok thanks for the response. How can we get more people to test this?

@d0ugal
Copy link
Member

d0ugal commented Apr 29, 2016

That is one of the eternal problems with open source software :) How do you get people to dedicate the time to trying things you want to add before you do a merge or release?

I'll try and get round to this over the next week. As such I have added it to the 0.16 release that I am working towards.

@robertmclaws
Copy link

So, I just wanted to jump in with the fix I put in my stylesheets. I use category sections, and the alignment of the items would have been fine if I didn't use categories, but was not fine because I did. I don't think the styling for the TOC is granular enough to account for the additive padding. Meaning each UL in the TOC should have a padding-left value of 0.81em, instead of applying the padding on the LIs.

If you do that, each subsequently nested UL should have the right padding.

At any rate, I put this in my override CSS and it did the trick:

.wy-menu-vertical li.current > a {
    padding-left: 2.42em;
}
.wy-menu-vertical li.current > ul li a {
    padding-left: 3.23em;
}

You can see it in action at http://restier.readthedocs.io/en/latest/getting-started/.

HTH!

@styfle
Copy link
Contributor Author

styfle commented Jun 6, 2016

@advancedrei That works great for subnavs but the top level is misaligned.
Try adding a two .md files in the root directory: index.md and websites.md.

It will look like this:

image

image

I think what you want is:

.wy-menu-vertical .subnav li.current > a {
    padding-left: 2.42em;
}
.wy-menu-vertical .subnav li.current > ul li a {
    padding-left: 3.23em;
}

@robertmclaws
Copy link

Yep, that did the trick. I think that should be added to the stylesheet for the next release.

@styfle
Copy link
Contributor Author

styfle commented Jun 6, 2016

@advancedrei I changed this pull request to use that snippet.

@waylan waylan merged commit 2c547a4 into mkdocs:master Aug 16, 2016
@styfle
Copy link
Contributor Author

styfle commented Aug 17, 2016

Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants