css-element-queries icon indicating copy to clipboard operation
css-element-queries copied to clipboard

Is there support for "orientation: portrait" queries?

Open jurgenhaas opened this issue 5 years ago • 3 comments

We currently use some media queries orientation: portrait and orientation: landscape in order to stack block side by side or on top of each other, depending on the orientation of the screen.

Now, with element queries it would be cool to have something similar. It doesn't have to be direct support of orientation, I'd also be happy if there was somethin like width > height or not.

Is something like that possible?

jurgenhaas avatar Feb 07 '20 15:02 jurgenhaas

So, you mean you want to apply rules to certain elements when they width > height, or height > width? We could integrate something like that:

.element[min-width~="200px"] {
    //normal csseq rule
}

.element[orientation="landscape"] {
    //only when width > height
}

.element[orientation="portrait"] {
    //only when height > width
}

What if height === width? None of them would apply.

So this is possible, but not planned. If you want to provide a PR, I'm open to merge it though.

marcj avatar Feb 13 '20 18:02 marcj

Thanks @marcj yes, that's the idea behind the request. The requirement is not high priority right now but I keep it in mind and will provide a PR when work load permits.

jurgenhaas avatar Feb 14 '20 07:02 jurgenhaas

+1 for orientation support.

steveoriol avatar May 03 '21 13:05 steveoriol