js 自适应高度

boxheight()
function boxheight() {
    //获取浏览器窗口高度
    var winHeight = 0
    if (window.innerHeight)
        winHeight = window.innerHeight
    else if ((document.body) && (document.body.clientHeight))
        winHeight = document.body.clientHeight
    //通过Document对body进行检测,获取浏览器可视化高度
    if (document.documentElement && document.documentElement.clientHeight)
        winHeight = document.documentElement.clientHeight
    if (winHeight > 100) {
        winHeight = winHeight - 80
    }
    //DIV高度为浏览器窗口高度
    document.getElementById("lis").style.height = winHeight + "px"
}
window.onresize = boxheight;

猜你喜欢

转载自blog.csdn.net/qq_32109957/article/details/90664826