Disable hover background on Ferris in short code snippets #4531
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4529, see that issue for more details.
Tested only by editing the CSS live using dev tools. Did so in both Firefox and Chromium, results look good.
Background
For short code snippets (fewer than 4 lines) which need Ferris, Ferris is made smaller and placed with the buttons. Some CSS from mdBook then applies to it unintentionally, giving it an ugly background when hovered over:
(Colors will be different depending on theme)
All relevant existing code is referenced in #4529 (comment) and #4529 (comment)
This PR simply changes the background back to transparent, fixing the issue.
Alternatives
It might be cleaner to change the selector in the rule in mdBook so it only applies to buttons in the first place:
https://github.com/rust-lang/mdBook/blob/780fd83cacef0471e876f596949aaf71a2dc2b10/crates/mdbook-html/front-end/css/chrome.css#L238-L242
Change the selector to:
pre > .buttons button:hoverBut that would potentially affect other users of mdBook so it's probably a bad idea.
It might also be worth considering moving Ferris outside of the buttons. Which brings me to...
Side notes
Is small Ferris too small? It certainly seems that way to me.