媒体查询

156 阅读1分钟

媒体:手机/平板/电脑屏幕 screen ,打印机(print)

作用:当屏幕宽度在某范围时,样式分变化

单位:

vw:view width(视口宽度) vh:view height(视口高度)

0-100vw  视口宽度百分比
0-100vh  视口高度百分比

写法

@media 媒体/all (所有媒体)

关键字:and并且 , not非 , only(基本不用)
@media screen and (max-width: 1000px) {
  .container {
    background-color: black;
    color: aliceblue;
  }
  .container div {
    margin: 40px 0 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-flow: column;
  }
}