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

Multiple media queries do not cascade #497

Open
glitteringkatie opened this issue Feb 22, 2019 · 3 comments
Open

Multiple media queries do not cascade #497

glitteringkatie opened this issue Feb 22, 2019 · 3 comments

Comments

@glitteringkatie
Copy link

glitteringkatie commented Feb 22, 2019

We have the following two media queries and expect them to apply in a cascading way.

[ Css.Media.withMedia
    [ only screen
        [ minWidth (px 1)
        , maxWidth (px 800)
        ]
    ]
    [ Css.width (Css.pct 32)
     , Css.height (Css.px 100)
    ]
, Css.Media.withMedia
    [ only screen
        [ minWidth (px 1)
        , maxWidth (px 376)
        ]
    ]
    [ Css.width (Css.pct 48)
    , Css.height (Css.px 100)
    ]
]

Instead, once the smaller size is hit, the 800 styles override the 376 styles.
image

@rtfeldman
Copy link
Owner

It's been awhile since I spent time in the media queries portion of this code base, but as I recall, there are some unfortunate design constraints elsewhere which make it impossible for this to work as expected.

I believe the solution is to change the top one from minWidth (px 1) to minWidth (px 377). Let me know if that works!

@brookeangel
Copy link
Collaborator

👍 Thanks for getting back to us and bummer about the design constraints. The suggestion does seem to work, so thanks you!

@Matsemann
Copy link

Having the same issues.
Here it works defining them in the opposite order in elm-css of what you normally would do with css media queries, then the style tag comes out with them correct.

For instance, if I define mediaQueryA and mediaQueryB in that order in elm-css, the <style>-tag it outputs contains them in the reverse order, so mediaQueryB above mediaQueryA.

This may be arbitrary, but at least it works in my case here. Just a tad annoying having to do it the opposite way of what I do when writing css. Not sure if we can depend on that order, though?

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

4 participants