Skip to content

Conversation

@NeatNit
Copy link

@NeatNit NeatNit commented Oct 18, 2025

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:

Image

(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:hover
But 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.

nixxo added a commit to nixxo/rust-lang-book-it that referenced this pull request Oct 20, 2025
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.

Ferris gets ugly background when hovered over on short code snippets

1 participant