CSS selector based on width?

前端 未结 4 749
灰色年华
灰色年华 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:26

    It is not possible to do it using CSS3, but you can use Element Queries. Check this library: https://elementqueries.com

    Here is an example:

    @element code and (max-width: 200px) {
      :self {
        white-space: nowrap;
      }
    }
    

提交回复
热议问题