CSS selector based on width?

前端 未结 4 742
灰色年华
灰色年华 2020-12-04 02:00

Is there a CSS rule that would match elements based on their width? If not, would it be interesting to propose that in the standard?

One could do something like

4条回答
  •  旧巷少年郎
    2020-12-04 02:17

    I just saw an example of media queries within a selector, effectively the same thing, although a pseudo-selector would be very nice and likely supplant media queries. I think it would be nice to have a new pseudo-selector :aspect-ratio(4:3) supporting ranges like :aspect-ratio(>4:3). This would be super convenient for styling responsive elements based on their orientation and width to height ratio.

提交回复
热议问题