screen width vs visible portion

前端 未结 3 1172
南笙
南笙 2020-12-06 06:58

I have a little problem with JavaScript, to get the screen width we use screen.width which returns the overall screen resolution, is there a command to get the resolution of

3条回答
  •  执笔经年
    2020-12-06 07:17

    I saw that the question was answered, but here is the code I used with an image to ilustrate.

    function height(){
    return(window.innerHeight)?
    window.innerHeight:
    document.documentElement.clientHeight||document.body.clientHeight||0;
    }
    $(document).ready(function(){
    $('.first, .second').css('height',height());
    });
    $(window).resize(function() {
    $('.first, .second').css('height',height());
    });
    

    JSFiddle Example

提交回复
热议问题