-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Hover state for headers' permalinks is weird #843
Comments
I'm not seeing this behavior in Chrome on Linux. Everything looks fine to me. What browser are you using? |
I see the incorrect behavior you are describing in your screenshot, but am not able to reproduce it locally. |
Yeah, confirmed on Chrome 48 (on Fedora). I can see this bug. Just move your mouse around a bit and it'll sometimes show the header link when you are not over any header at all (and usually it then shows the header below where you are). |
Right. If you inspect the element, you can see why: It's actually much larger than just the line of text, since the |
Cool, yeah, I spotted that too. I think I've fixed it in #844. |
Meanwhile, if you use extra_css and add the following, it should fix it for you (and let you confirm my fix which would be super helpful! 🌟). h1[id]:before, h2[id]:before, h3[id]:before, h4[id]:before, h5[id]:before, h6[id]:before {
content: "";
display: block;
pointer-events: none;
} |
Unfortunately, I think that patch will cause the header itself to be hidden by the navbar at the top (which is why that padding/negative-margin trick was there in the first place). I delved into the history, and it used to have a JS implementation: #407. |
aha, that's what that height hack was for! We should really use comments. |
Yeah, any time there's a negative margin in CSS, there should probably be a comment. :) |
Well, that's a shame I was feeling clever for a moment. I'll finish my coffee and think about it for a bit. |
A partial fix would be to change the CSS to: :target::before {
content: "";
display: block;
margin-top: -75px;
height: 75px;
pointer-events: none;
} The above will ensure that all the headers, except the one referred to in the URL's hash, will work fine. You could probably be really tricky and turn the selector into something like The real solution is for CSS to have some sort of |
Oh, that is neat. I didn't know you could do |
Ok, I think I have a patch for this. It's fairly bizarre, so I need to clean it up and add some comments. Then I'll file a PR. |
…s correctly; resolves mkdocs#843
@d0ugal Ok, the PR is up. I added a comment that hopefully explains all the weird magic I performed. I can also add vendor-specific CSS prefixes as appropriate if you think they're necessary. Here's a compatibility chart: https://developer.mozilla.org/en-US/docs/Web/CSS/animation#Browser_compatibility |
…s correctly; resolves mkdocs#843
…s correctly; resolves mkdocs#843
Navbar is not a custom feature? How to maintain a custom CSS-code (ex. change navbar backgroundcolor) in a ugly and mixed-bootstrap CSS code? |
Try going to http://www.mkdocs.org/ and put your mouse to the right of "Host anywhere". You'd expect to see the permalink for that heading, but instead, the permalink for "Great themes available" shows up. This can be pretty annoying, since it makes it harder to click on the permalink; if you go a pixel too far to the right, you have to move your mouse back over the text itself, and then back again to the permalink.
As far as I can tell, this is because of the following code: https://github.com/mkdocs/mkdocs/blob/master/mkdocs/themes/mkdocs/css/base.css#L43-L49. I gather that it's there to work around the existence of the header so that anchor links go to the right spot. I'd argue that the old Javascript way was better, unless someone can figure out a way to trick CSS into handling the hover state better.
The text was updated successfully, but these errors were encountered: