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

Massive issue with sizes affecting Tailwind and other frameworks. #1293

Open
MarioAda opened this issue Mar 19, 2024 · 0 comments
Open

Massive issue with sizes affecting Tailwind and other frameworks. #1293

MarioAda opened this issue Mar 19, 2024 · 0 comments

Comments

@MarioAda
Copy link

"@nuxt/image": "^1.4.0"
"nuxt": "^3.7.3"

I quote the documentation:

This default size is used up until the next specified screen width, and so on. Each specified size pair applies up - so md:400px means that the image will be sized 400px on md screens and up.

However, the max-width value is wrong and incompatible with Tailwind and most toolkits and frameworks.

Here's an example:
image

It says (max-width: 640px) 100vw because I have xs:100vw in the sizes attribute. Note that 640px screens are included, which is the problem!

In Tailwind, if we have grid-cols-1 sm:grid-cols-2, we'll split the row in 2 on screens sized 640px+, so a 100vw image becomes 50vw. However, NuxtImg will still load the 100vw image on 640px screens and will only load the 50vw image on 641px+!

The solution is to update screens to:

screens: {
    xs: 319,
    sm: 639,
    md: 767,
    lg: 1023,
    xl: 1279,
    "2xl": 1535,
}
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

No branches or pull requests

1 participant