CSS grid + media queries

Hello,
so I have a CSS grid and I am trying to modify this grid conf when it hits a certain media query.
What I do is what follows:
Under the Style panel, I duplicate my grid. Select this new duplicated grid and under the " Selector and media queries " I set it to smaller than 1024px.

I resize my screen to say 1020px, select the grid and then I open the visual helper.


Now I modify the CSS grid structure to something like this (see below). But this will modify my grid for both the two breakpoints.

so…I redo the whole thing but this time on the visual helper, under “CSS Rule” I select the rule (max-width:1023px).myclass and modify my grid.

This time nothing happens. The grid remains as it is as I jump from one media query to the other.

Any hint?
Thanks in advance to anyone.

Hi @red-rosefields,
Do you have a screenshot of the rules displayed in Active tab in the Style panel with the Page View set to a size less than 1024px? I suspect we will see that the order of the rules will be the @media rule being displayed second.


This actually means that it was loaded in before the non-media query rule for the element. The rule higher up in the Active tab will be loaded later by the browser. Since both rules would apply at screen sizes smaller than 1024px, the rule loaded last wins. So, to solve this, you would have to reorder your rules to make sure your media query is at the end of your stylesheet (or at least after the initial rule). You can do that either in the code editor, or by clicking on the stylesheet dropdown in the Style panel, selecting the stylesheet by clicking on the name to open it is a new tab, and finally using the drag bars to the right of the rule name to move them either up or down.

The trick to adding media queries in Pinegrow is that after you duplicate the rule, you want to select the rule that is higher up in the Active tag before adding the media query. That way it always comes after the original ruleset.

Let me know if this solves it or I am completely wrong!

Cheers,
Bob

1 Like

@RobM Thank you so much for the help! That fixed my issue.

The trick to adding media queries in Pinegrow is that after you duplicate the rule, you want to select the rule that is higher up in the Active tag before adding the media query.

My new mantra.