-
Notifications
You must be signed in to change notification settings - Fork 151
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
vh-based rules don't respect media queries #13
Comments
I see the problem. The "simple" solution would be to simply grab the entire source CSS, replace the viewport units and dump it back into the DOM. Looking for succeeding rules that might or might not override a viewport-unit-using-rule seems like too much trouble to go through. |
I just had this exact issue - would be great if there was a fix but I can see how tricky it would be to solve. Would your "simple" solution have performance drawbacks? |
Without having this tested I would say "yes". We would be replacing the entire CSS with every change to the viewport (resize, orientationchange). Depending on the device's performance and the amount of CSS you throw at it, this might take a little while. The browser has to parse the CSS, style (calculate the styles for each element), layout (calculate the layout based on changed style), paint (draw the result of the layout) for the entire document - instead of, in the best case, only couple of elements. |
+1 |
I think I have the same issue: http://lab.gasteroprod.com/vub/ I had to add This lib could at least duplicate rules that have values like |
That would mean the lib had to understand what |
Why would it be necessary, if they are simply copied into the new rules? Feels safe IMHO, and really better than copying everything. |
I think I didn't make this clear enough. The library doesn't need to know what
Why stop at We should either fix it "properly" (whatever that is), or leave it open as a known issue if we can't. |
Ok, makes sense.
My example shows that these values, when set in a MQ, are ignored because the value set by the lib outside the MQs (Mobile First CSS…) is inline, with greater specificity. |
Maybe it's more obvious when comparing http://lab.gasteroprod.com/vub/index-bugfill-issue.html and http://lab.gasteroprod.com/vub/index-bugfill-fixed.html on thin and large screen (MQ at 20em). There is only one |
I understand the problem just fine, only the suggested solution did not compute. I stand by comment 1, transforming the entire CSS into one |
Simplest maybe, but dangereous for performances, as already said… :-/ |
Hi everyone!! Any news regarding this issue? |
I've been hit once again by this issue on http://alpha.esviji.com on iOS… :-/ I had to add |
Huh, that took a while for me to narrow down in my project. I see why it wouldn't be easy to fix, though. |
I've been able to handle vh & media-queries by doing a very different thing… https://github.com/Hiswe/vh-check If you see something wrong with the approach (or the code), let me know :) |
I guess another work around for this is writing your css mobile-first. Make your breakpoints apply style overrides to desktop resolutions as opposed to the opposite way around. |
With the UI / URL Bar collapsing and revealing on iOS chrome, my hero images using vh units were shrinking and expanding on scroll and it was driving me nuts! I've spent about 6 hours on this issue. I've ended up opting for a solution posted on CSS-Tricks by Louis Hoebregts. It goes like this... In your Javascript (in my case, React) add:
Then in your CSS add:
More here: https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ |
Solved this issue with the calculated vh in a React project using this library: https://github.com/mvasin/react-div-100vh |
When I write rules in media queries, I noticed that the last rule of a given selector using vh units override any succeeding rule targeting the same selector bu using different units (i.e. not vh). Also, the same vh-based rule inside any media queries will get executed regardless of whether the query returns true or not.
I understand that your implementation pulls vh-based rules out of stylesheets and into the HTML, but perhaps you could make it so that every succeeding use of the selector gets pulled as well, and that any wrapping media queries is also grabbed.
The text was updated successfully, but these errors were encountered: