响应式布局

2022/3/4

# 媒体查询

# 视口常用值

  • pc浏览器可用宽度:pc端随着放大而缩小onresize
  • 手机上是布局视口宽度
    document.documentElement.clientWidth
    
    1
  • 包括滚条的可视宽度:
    window.innerWidth
    
    1
  • 可视宽度+浏览器边框:
  • 手机上是视觉视口
    window.outerWidth
    
    1
  • 显示设备宽度:
    screen.width
    
    1

# 移动端视口

# 移动端适配

# 是否触摸屏

const canHover = matchMedia("(hover: hover)").matches;
1

# 是否IE

export function isIE() {
  if (!!window.ActiveXObject || "ActiveXObject" in window) {
    return true;
  }
  return false;
}
1
2
3
4
5
6
上次更新: 9/17/2024