make iframe height dynamic based on content inside- JQUERY/Javascript

前端 未结 20 2320
情书的邮戳
情书的邮戳 2020-11-22 07:42

I am loading an aspx web page in an iframe. The content in the Iframe can be of more height than the iframe\'s height. The iframe should not have scroll bars.

I have

20条回答
  •  情书的邮戳
    2020-11-22 08:16

    This one is useful when you require a solution with no jquery. In that case you should try adding a container and set a padding to it in percentages

    HTML example code:

    CSS example code:

    .iframeclass{
        position: absolute;
        top: 0;
        width: 100%;
    }
    
    .iframecontainer{
        position: relative;
        width: 100%;
        height: auto;
        padding-top: 61%;
    }
    

提交回复
热议问题