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

Nested media queries instead of the 0.02px workaround? #49

Open
simevidas opened this issue Oct 14, 2023 · 1 comment
Open

Nested media queries instead of the 0.02px workaround? #49

simevidas opened this issue Oct 14, 2023 · 1 comment

Comments

@simevidas
Copy link

@miragecraft posted on Twitter the following discovery:

@media (width < 640px) {
  /* styles */
}

/* is the same as */

@media (max-width: 640px) {
  @media not (width: 640px) {
    /* styles */
  }
}

This seems like a better output than the (max-width: 639.98px) workaround that this plugin currently uses. Has this solution ever been considered?

@romainmenke
Copy link

romainmenke commented Oct 18, 2023

Is there an example where (max-width: 639.98px) causes issues?

Nested media queries wasn't always supported : https://developer.mozilla.org/en-US/docs/Web/CSS/@media#browser_compatibility:~:text=Nested%20media%20queries


Another issue is that the proposed transform quickly escalates in complexity :

How do these examples transform?
How do you program the plugin to transform correctly in all edge cases?

@media ((width < 640px) or (height < 400px)) {
  /* styles */
}

@media not print and (width < 640px) {
  /* styles */
}

Keeping the same overal query but changing the values is the least impactful change and therefor more likely to be correct.

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

2 participants