纵横比 | @media.aspect-ratio (Media Queries) - CSS 中文开发手册 - Break易站

2021-01-27 05:14

阅读:725


  • ??CSS 中文开发手册

    纵横比 | @media.aspect-ratio (Media Queries) - CSS 中文开发手册

    该aspect-ratio CSS @media媒体功能可用于应用基础上的纵横比视觉效果。

    语法

    该aspect-ratio特征被指定为 值表示表示视口的宽高比宽高比的值。这是一个范围功能,这意味着您也可以使用前缀min-aspect-ratio和max-aspect-ratio变量分别查询最小值和最大值。

    HTML

    Watch this element as you resize your viewport‘s width and height.

    CSS

    /* Exact aspect ratio */
    @media (aspect-ratio: 1/1) {
      div {
        color: red;
      }
    }
    
    /* Minimum aspect ratio */
    @media (min-aspect-ratio: 8/5) {
      div {
        background: yellow;
      }
    }
    
    /* Maximum aspect ratio */
    @media (max-aspect-ratio: 2/1) {
      div {
        border: 2px solid blue;
      }
    }

    结果

    规范

    Specification

    Status

    Comment

    Media Queries Level 4The definition of ‘aspect-ratio‘ in that specification.

    Working Draft

    No change.

    Media QueriesThe definition of ‘aspect-ratio‘ in that specification.

    Recommendation

    Initial definition.

    浏览器兼容性

    Feature

    Chrome

    Firefox (Gecko)

    Internet Explorer

    Opera

    Safari

    Basic support

    ?

    3.5 (1.9.1)

    9.0

    ?

    ?

    Feature

    Android

    Firefox Mobile (Gecko)

    IE Mobile

    Opera Mobile

    Safari Mobile

    Basic support

    ?

    ?

    ?

    ?

    ?

    
    
  • ??CSS 中文开发手册

  • 评论


    亲,登录后才可以留言!