js实现div铺满整个屏幕

export function getWindows(id){

let baseid=document.getElementById(id)

console.log(baseid)

const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width

const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height

console.log(width)

console.log(height)

console.log(baseid.style)

baseid.style.width = width+'px'; 

  baseid.style.height =height+'px'; 

}

//用法

// getWindows("baseId");

//  window.onresize=function(){

// getWindows("baseId")

//  } 

你可能感兴趣的:(js实现div铺满整个屏幕)