diff --git a/src/app/components/url-preview/UrlPreview.css.tsx b/src/app/components/url-preview/UrlPreview.css.tsx index a62d7c9f9..5eac2acee 100644 --- a/src/app/components/url-preview/UrlPreview.css.tsx +++ b/src/app/components/url-preview/UrlPreview.css.tsx @@ -246,11 +246,15 @@ export const EmbedMediaPortrait = style([ DefaultReset, { position: 'relative', - width: toRem(300), - maxWidth: '100%', - // 9:16 via the padding-top hack (177.78%) — see EmbedMediaLandscape. + // [Gitea #228] `min()` on both axes so the 9:16 ratio holds whatever the + // parent's width is. A padding-top percentage resolves against the + // CONTAINING BLOCK's width, not the element's, so a bare `177.78%` inside a + // wide card made the box ~2x too tall (606px card → 1077px instead of 533). + // Capped at the pixel height of a 300px-wide 9:16 box, it is exact when the + // parent is at least 300px and falls back to the percentage below that. + width: `min(${toRem(300)}, 100%)`, height: 0, - paddingTop: '177.78%', + paddingTop: `min(${toRem(533)}, 177.78%)`, margin: '0 auto', overflow: 'hidden', backgroundColor: color.Surface.Container, diff --git a/src/app/components/url-preview/UrlPreviewCard.tsx b/src/app/components/url-preview/UrlPreviewCard.tsx index c037efb0e..ee80f58e3 100644 --- a/src/app/components/url-preview/UrlPreviewCard.tsx +++ b/src/app/components/url-preview/UrlPreviewCard.tsx @@ -1203,7 +1203,11 @@ function MediaEmbedCard({ }; return ( - + // [Gitea #228] `width: 100%` — UrlPreview is a flex ROW, so this column + // shrink-to-fits its content. The facade's supplied that width, but + // the player