w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.36k stars 641 forks source link

[mediaqueries-5] Logical Media Queries #10156

Open brandonmcconnell opened 3 months ago

brandonmcconnell commented 3 months ago

Abstract

This proposal introduces new media queries that are based on the logical inline and block dimensions of the viewport, rather than width and height. This aligns with the growing support for logical styles in modern web development.

Motivation

Current CSS media queries are based on the width and height of the viewport, which can be problematic when dealing with layouts that are not constrained to a single axis (e.g. responsive designs, rotated screens, internationalization, etc.). This proposal aims to provide a more flexible and logical way to target styles based on the inline and block dimensions of the viewport.

Proposed Media Queries

block inline
range (min-block: <size>)
(max-block: <size>)
(min-inline: <size>)
(max-inline: <size>)
operator (block > <size>)
(block >= <size>)
(block < <size>)
(block <= <size>)
(inline > <size>)
(inline >= <size>)
(inline < <size>)
(inline <= <size>)

Use Cases

Conclusion

This proposal aims to introduce a more logical and flexible approach to media queries in CSS, aligning with the growing trend towards layout-agnostic web design. By focusing on the inline and block dimensions of the viewport, rather than the physical width and height, developers can create more robust and adaptable styles for a wide range of device and layout scenarios.

KennethHoff commented 2 months ago

Should these not be {max-/min-}block-size and {max-/min-}inline-size respectively?

brandonmcconnell commented 2 months ago

Should these not be {max-/min-}block-size and {max-/min-}inline-size respectively?

@KennethHoff Perhaps!