-
-
Notifications
You must be signed in to change notification settings - Fork 931
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent code badges from scrolling along with code
The `::before` trick we've been using to add badges has never interacted well with the `overflow-x: auto` we set on the parent `<pre>`: `position: absolute` positions relative to the unscrolled container and doesn't "stick" when the container is scrolled, resulting in the badge leaving the right edge of the block when wide code is scrolled. Until now, that issue has been masked by the fact that highlight.js gives the `<code>` its own `overflow-x: auto`. Since we've stopped using highlight.js, we need to fix the issue properly. The root cause is described well in this article[1]. As it demonstrates, all solutions not involving an extra wrapper div take a lot of code and are pretty hacky. In addition, the last example--closest to our case-- requires the badge itself to have nested divs, which can't be done with `::before`. As such, just use JS to add a wrapper div, which actually simplifies both the CSS and the JS significantly. [1] https://www.horuskol.net/blog/2022-04-13/relative-and-absolute-scrolling-blues/
- Loading branch information
Showing
2 changed files
with
53 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters