Skip to content

Fix copy button overlapping code and scrolling on small screens#51

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-copy-button-overlapping-code
Draft

Fix copy button overlapping code and scrolling on small screens#51
Copilot wants to merge 4 commits intomainfrom
copilot/fix-copy-button-overlapping-code

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

The copy button was appended inside pre.highlight, which sits inside the horizontally-scrollable div.highlight wrapper — causing it to overlap code on narrow viewports and scroll with the content when swiping right.

Changes

  • assets/copy-code.js — append button to div.highlighter-rouge (non-scrollable outer container) instead of pre.highlight
  • assets/index.css — add position: relative to div.highlighter-rouge as the new stacking context; move button selector from pre.highlight > buttondiv.highlighter-rouge > button; change position to bottom-right; remove mx-4 margins that were causing leftward drift; drop position: relative from pre.highlight
  • dist/style.*.css — compiled output updated to match
/* before: button inside scrollable pre, top-right with margin drift */
pre.highlight { position: relative; }
pre.highlight > button { position: absolute; top: .25rem; right: .25rem; margin: 0 1rem; }

/* after: button anchored to outer non-scrollable container, bottom-right */
div.highlighter-rouge { position: relative; }
div.highlighter-rouge > button { position: absolute; bottom: .25rem; right: .25rem; }
Original prompt

This section details on the original issue you should resolve

<issue_title>The copy code button is overlapping the code on smaller screens. </issue_title>
<issue_description>With the newly added copy code button a new bug was introduced where said button overlaps the actual code example. As you can see in the attached image.

IMG_5951
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ight to pre.highlight

Co-authored-by: DannyvdSluijs <618940+DannyvdSluijs@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix overlap of copy code button on smaller screens Fix copy button overlapping code on small screens Feb 28, 2026
@DannyvdSluijs
Copy link
Member

@copilot On a small screen (iPhone SE for example) the copy button remains overlapping, see attached image
Screenshot 2026-03-08 at 18 22 23
Also the copy button moves when scrolling to the right.

…tton outside scrollable container

Co-authored-by: DannyvdSluijs <618940+DannyvdSluijs@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 8, 2026

@copilot On a small screen (iPhone SE for example) the copy button remains overlapping, see attached image
<img width="298" height="124" alt="Screenshot 2026-03-08 at 18 22 23" src=...

Fixed in commit 3d4196e. The root cause was that the button was appended inside pre.highlight, which lives inside the horizontally-scrollable div.highlight wrapper — so the button scrolled along with the code and continued to overlap it.

The fix moves the button to the outer div.highlighter-rouge container (which is not scrollable), so it always stays pinned to the top-right corner of the code block regardless of horizontal scrolling or screen size. CSS changes:

  • position: relative added to div.highlighter-rouge (positioning context for the button)
  • CSS selector changed from pre.highlight > buttondiv.highlighter-rouge > button
  • Removed the now-unnecessary padding-right and position: relative from pre.highlight

Copilot AI changed the title Fix copy button overlapping code on small screens Fix copy button overlapping code and scrolling on small screens Mar 8, 2026
…g margins

Co-authored-by: DannyvdSluijs <618940+DannyvdSluijs@users.noreply.github.com>
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.

The copy code button is overlapping the code on smaller screens.

2 participants