Skip to content

Website: rem with font-size: 62.5% breaks srcset #11791

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

Closed
leoj3n opened this issue Feb 3, 2024 · 2 comments
Closed

Website: rem with font-size: 62.5% breaks srcset #11791

leoj3n opened this issue Feb 3, 2024 · 2 comments
Labels
documentation Improvements or additions to documentation meta

Comments

@leoj3n
Copy link
Contributor

leoj3n commented Feb 3, 2024

Describe the bug

I believe the current https://kit.svelte.dev website has an issue when using rem and srcset:

html
{
  ...
  font-size: 62.5%;
}
<picture>
  <source srcset="/_app/immutable/assets/svelte-kit-machine.QxzWJJCG.avif 1440w, /_app/immutable/assets/svelte-kit-machine.bRNI6fne.avif 1080w, /_app/immutable/assets/svelte-kit-machine.F02x6KOB.avif 768w, /_app/immutable/assets/svelte-kit-machine.xbq8eY7V.avif 640w" sizes="(min-width: 768px) min(100vw, 108rem), 64rem" type="image/avif">
  <source srcset="/_app/immutable/assets/svelte-kit-machine.8mPpps5Z.webp 1440w, /_app/immutable/assets/svelte-kit-machine.fsRU-V14.webp 1080w, /_app/immutable/assets/svelte-kit-machine.MJuQ2NRQ.webp 768w, /_app/immutable/assets/svelte-kit-machine.1ON3IFXZ.webp 640w" sizes="(min-width: 768px) min(100vw, 108rem), 64rem" type="image/webp">
  <source srcset="/_app/immutable/assets/svelte-kit-machine._UWkb_B3.png 1440w, /_app/immutable/assets/svelte-kit-machine.Wpp9Ptlg.png 1080w, /_app/immutable/assets/svelte-kit-machine.oSMVCmBL.png 768w, /_app/immutable/assets/svelte-kit-machine.7PYg01mw.png 640w" sizes="(min-width: 768px) min(100vw, 108rem), 64rem" type="image/png">
  <img src="/_app/immutable/assets/svelte-kit-machine._UWkb_B3.png" class="hero-image svelte-m2ltu" alt="SvelteKit illustration" width="1440" height="1440">
</picture>

For <img> with DPR 1 and viewport of ~400px:

> $0.clientWidth
640
> $0.currentSrc
"https://kit.svelte.dev/_app/immutable/assets/svelte-kit-machine.bRNI6fne.avif"

image

The smaller 640w *xbq8eY7V.avif image should be the current source in this case.

Reproduction

https://kit.svelte.dev

Logs

No response

System Info

Any modern web browser.

Severity

annoyance

Additional Information

https://stackoverflow.com/questions/30653280/how-do-responsive-images-work-with-em-supplied-as-a-length-in-sizes

@leoj3n
Copy link
Contributor Author

leoj3n commented Feb 3, 2024

Perhaps you can keep the html { font-size: 62.5%; } if sizes used calc:

sizes="(min-width: 768px) min(100vw, calc(108rem * .625)), calc(64rem * .625)"

@gtm-nayan gtm-nayan added documentation Improvements or additions to documentation meta labels Mar 24, 2024
@eltigerchino
Copy link
Member

eltigerchino commented Oct 26, 2024

closing this as stale since the new svelte.dev omnisite is up

@eltigerchino eltigerchino closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation meta
Projects
None yet
Development

No branches or pull requests

3 participants