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(theme-default): ensure proper sizing of SVG hero images #4639

Merged
merged 3 commits into from
Mar 21, 2025

Conversation

GabrielxDuO
Copy link
Contributor

Description

When using vector graphics (SVGs) without specified dimensions as hero images, they can render at unexpectedly small sizes in certain viewport widths. This creates inconsistent presentation compared to bitmap images.

Before/After Comparison

WebP SVG
Before before-webp before-svg
After after-webp after-svg

@brc-dd brc-dd merged commit 7d94481 into vuejs:main Mar 21, 2025
9 checks passed
@GabrielxDuO
Copy link
Contributor Author

Yes, I also tried using the following approach:

width: 100%;
height: 100%;
object-fit: contain;

However, thinking back to when I tested it with vitepress-logo-large.webp, the inconsistency might have been caused by an outer glow or shadow (as opposed to the glow in vitepress-logo-large.svg, which is achieved using filter), making the .webp version appear slightly larger and therefore seem to scale down more noticeably.

That said, considering the broader issue that the hero image may not always be square, this solution (object-fit: contain) is indeed better suited. Thank you for making these adjustments!

@brc-dd
Copy link
Member

brc-dd commented Mar 21, 2025

Yeah, and the webp was also of older version I think.

image


(left one is svg, right is webp)

Also the webp had padding inside the image itself, and in svg it's just padding: 18px from css. So some difference might be because of that 👀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants