How do I make a div full screen?

后端 未结 10 1781
耶瑟儿~
耶瑟儿~ 2020-12-07 10:59

I am using Flot to graph some of my data and I was thinking it would be great to make this graph appear fullscreen (occupy full space on the monitor) upon clicking on a butt

相关标签:
10条回答
  • 2020-12-07 11:30
    <div id="placeholder" style="position:absolute; top:0; right:0; bottom:0; left:0;"></div>
    
    0 讨论(0)
  • 2020-12-07 11:34

    CSS way:

    #foo {
       position: absolute;
       top: 0;
       right: 0;
       bottom: 0;
       left: 0;
    }
    

    JS way:

    $(function() {
        function abso() {
            $('#foo').css({
                position: 'absolute',
                width: $(window).width(),
                height: $(window).height()
            });
        }
    
        $(window).resize(function() {
            abso();         
        });
    
        abso();
    });
    
    0 讨论(0)
  • 2020-12-07 11:41

    u can try this..

    <div id="placeholder" style="width:auto;height:auto"></div>
    

    width and height depends on your flot or graph..

    hope u want this...

    or

    By clicking, u can use this by jquery

    $("#placeholder").css("width", $(window).width());
    $("#placeholder").css("height", $(window).height());
    
    0 讨论(0)
  • 2020-12-07 11:42

    When you say "full-screen", do you mean like full-screen for the computer, or for taking up the entire space in the browser?

    You can't force the user into full-screen F11; however, you can make your div full screen by using the following CSS

    div {width: 100%; height: 100%;}
    

    This will of course assume your div is child of the <body> tag. Otherwise, you'd need to add the following in addition to the above code.

    div {position: absolute; top: 0; left: 0;}
    
    0 讨论(0)
提交回复
热议问题