You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm generating the critical CSS for my landing page for multiple screen dimensions. If the input CSS contains @media screen size selectors, then the order of the rules in the critical css generated output can change depending on the order of the screen dimensions list.
This is causing my landing page to render incorrectly on certain screen sizes.
This an excerpt from my input CSS (generated from SCSS):
The expected result is that the text size scales automatically with screen size (using vw units), but with a minimum and maximum size using @media queries.
On large screens the generic rule is overriding the @media (min-width: 800px) rule because it comes later in the file, so my font is too big.
If I reverse the order of my dimenions list then the resulting css is as expected (but there could be other order changes lurking in there).
The expected result is that the ultimate order of css rules remains unchanged regardless of the order that the different screen dimensions are rendered in.
I am using critical@next (2.0.0-23)
The text was updated successfully, but these errors were encountered:
wildhart
changed the title
Multiple resolutions causes order of css to change
Multiple resolutions causes order of css to change when @media rules are used
Nov 6, 2019
Good catch @wildhart. I've made some tests and it seems the order of the dimensions needs to be from small to wide. I'm enforcing this now by sorting the array so the order in which it's passed to critical doesn't matter.
I'm generating the critical CSS for my landing page for multiple screen dimensions. If the input CSS contains
@media
screen size selectors, then the order of the rules in the critical css generated output can change depending on the order of the screen dimensions list.This is causing my landing page to render incorrectly on certain screen sizes.
This an excerpt from my input CSS (generated from SCSS):
The expected result is that the text size scales automatically with screen size (using
vw
units), but with a minimum and maximum size using@media
queries.Here's my dimensions list:
This results in the following (unminified) critical CSS, (note the line numbers):
On large screens the generic rule is overriding the
@media (min-width: 800px)
rule because it comes later in the file, so my font is too big.If I reverse the order of my
dimenions
list then the resulting css is as expected (but there could be other order changes lurking in there).The expected result is that the ultimate order of css rules remains unchanged regardless of the order that the different screen dimensions are rendered in.
I am using critical@next (2.0.0-23)
The text was updated successfully, but these errors were encountered: