Adjust width and height of iframe to fit with content in it

前端 未结 30 2740
旧时难觅i
旧时难觅i 2020-11-22 02:09

I need a solution for auto-adjusting the width and height of an iframe to barely fit its content. The point is that t

30条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 02:46

    Here are several methods:

    
        
    
    

    AND ANOTHER ALTERNATIVE

    
        
    
    

    TO HIDE SCROLLING WITH 2 ALTERNATIVES AS SHOWN ABOVE

    
        
    
    

    HACK WITH SECOND CODE

    
        
    
    

    To hide the scroll-bars of the iFrame, the parent is made "overflow:hidden" to hide scrollbars and the iFrame is made to go upto 150% width and height which forces the scroll-bars outside the page and since the body doesn't have scroll-bars one may not expect the iframe to be exceeding the bounds of the page. This hides the scrollbars of the iFrame with full width!

    source: set iframe auto height

提交回复
热议问题