Skip to content

Fix code block layout issues caused by floated content#4884

Open
ryxxn wants to merge 2 commits intoshuding:mainfrom
ryxxn:fix/code-block-flow-root
Open

Fix code block layout issues caused by floated content#4884
ryxxn wants to merge 2 commits intoshuding:mainfrom
ryxxn:fix/code-block-flow-root

Conversation

@ryxxn
Copy link

@ryxxn ryxxn commented Dec 30, 2025

Why:

When floated content exists in the same area as a code block, the code block’s layout is not calculated correctly, causing the copy button to be rendered in an incorrect position.

As shown in the example below, the code block layout overlaps with the floated content.

image

As a result, the copy button appears to escape outside the code block area.

image

What's being changed (if available, include any code snippets, screenshots, or gifs):

To address this issue, display: flow-root is applied to the code block wrapper to properly contain floated content and prevent layout overlap.

Since Nextra uses Tailwind CSS, the x:flow-root utility class was added to fix this issue. The result is shown below.

image

Check off the following:

  • I have reviewed my changes in staging, available via the View
    deployment
    link in this PR's timeline (this link will be available after
    opening the PR).

Additional infomation

flow-root MDN
flow-root tailwindcss

@changeset-bot
Copy link

changeset-bot bot commented Dec 30, 2025

🦋 Changeset detected

Latest commit: 7f51331

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
nextra Patch
nextra-theme-blog Patch
nextra-theme-docs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
nextra-v2 Ready Ready Preview, Comment Dec 30, 2025 3:28am

@vercel
Copy link

vercel bot commented Dec 30, 2025

@ryxxn is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant