Skip to content

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

Open
@Zhang-Junzhi

Description

@Zhang-Junzhi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions