Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mask composite guides alignment #2195

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wongjn
Copy link
Contributor

@wongjn wongjn commented Apr 5, 2025

Fixes #2194

The math for the top-[calc(25%-2px)] classes were incorrect. The percentage should correspond to:

Where
  u is a spacing unit, `0.25em`
  L is the "mask-add/subtract/…" text's `line-height` = 0.75rem * ( 1 / 0.75 ) = 1rem = 4u
  M is the "mask-add/subtract/…" text's `mb-3` = 3u
  H is the masked images' height, `h-24` = 24u

Then
  Total height, T = L + M + H
                  = 4u + 3u + 24u
                  = 31u

  Masked image top offset, Q = L + M
                             = 4u + 3u
                             = 7u

  As a percentage = Q ÷ T
                  = 7u ÷ 31u × 100%
                  ≈ 22.6%

Thus to line everything up, the top should be top-[calc(700%/31-2px)].

However, since the bottom of each grid element is aligned to the bottom of the images, I'd thought it'd be simpler to offset the guide elements' Y position based of the bottom. Thus, we'd only need to offset their border width 2px, with -bottom-[2px].

Before After
Before After

Perhaps ideally we'd use a CSS variable to DRY all the 2px border width offsets but that seemed out of scope of this PR.

Copy link

vercel bot commented Apr 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tailwindcss-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 5, 2025 7:50pm

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.

Mask example images look unaligned
1 participant