Skip to content

env(viewport-segment-width/height ...) should provide RTL and BTT counting mechanisms. #11141

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

Open
Zhang-Junzhi opened this issue Nov 1, 2024 · 0 comments

Comments

@Zhang-Junzhi
Copy link
Contributor

Zhang-Junzhi commented Nov 1, 2024

Currently, env(viewport-segment-width/height ...) can only be counted left-to-right and top-to-bottom.

For example, it's easy to target the leftmost viewport segment(or counting from left to right):

/*Put the site navigation bar in the "start"(i.e. leftmost) screen in a LTR language page*/
html:dir(ltr) .nav
{
  position: fixed;
  @media (horizontal-viewport-segments >= 2)
  {
    left: calc(env(viewport-segment-width 0 0) / 2);
    width: calc(env(viewport-segment-width 0 0) / 4);
    ...
  }
}

Targeting the topmost(or counting from top to bottom) works as easy.

But there's no as easy logically equivalent way to target the rightmost/bottommost viewport segment(or counting from bottom to top):

  /*Put the site navigation bar in the "start"(i.e. rightmost) screen in a RTL language page:
  We can only "enumerate" media queries instead of simply using "@media (horizontal-viewport-segments >= 2)":*/
html:dir(rtl) .nav
{
  position: fixed;
  @media (horizontal-viewport-segments: 2)
  {
    right: calc(env(viewport-segment-width 1 0) / 2);
    width: calc(env(viewport-segment-width 1 0) / 4);
  }
  @media (horizontal-viewport-segments: 3)
  {
    right: calc(env(viewport-segment-width 2 0) / 2);
    width: calc(env(viewport-segment-width 2 0) / 4);
  }
  @media (horizontal-viewport-segments: 4) /*I know there's basically nothing like it at the moment*/
  {
    right: calc(env(viewport-segment-width 3 0) / 2);
    width: calc(env(viewport-segment-width 3 0) / 4);
  }
}

I know there's basically really rare devices with three or even more screens at the moment, it is currently tolerable to just "enumerate" two or three media queries , but as a spec, I think CSS at least needs to theoretically support the logical symmetry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants