Iframe's overflow problem

52,429

In short, it is not possible to have an overflowed iframe. This post gives an explanation.

To achieve the similar effect you're after, you're better off use AJAX to inject the embedded page into a div, and make the div overflow.

Share:
52,429
Pinki
Author by

Pinki

Updated on August 14, 2020

Comments

  • Pinki
    Pinki almost 4 years

    I have a simple page that contains an iframe. The iframe contains a page with some divs. When I open the embedded page separetely it works very well. The div that should be overflowed is overflowed. But when I open the container site it is not. Here are my codes:

    Container page:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    
        <style type="text/css">
                #content{
                    margin: auto;
                    width: 500px;
                    height: 1000px;
                    background: green;
                }
    
                #frame{
                    width:202px; 
                    height:302px; 
                    overflow: visible;
                }
        </style>
    
      </head>
    
      <body>
            <div id="content">
                <iframe id="frame"
                    src="http://localhost:8080/webApp/view/test/embeddable.html" 
                    scrolling="no" frameborder="0" allowTransparency="true" marginheight="0" marginwidth="0">
                </iframe>           
            </div>
      </body>
    </html>
    

    Embeddable page:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
      <head>
        <style type="text/css">
            body {
                width: 200px;
                height: 300px;
                overflow: visible;
                border: 1px solid yellow;
            }
    
                #id1{
                    margin: auto;
                    width: 500px;
                    height: 10px;
                    border: 1px solid white;
                    background: red;
                    margin-top: 20px;
                }
        </style> 
      </head>
    
      <body>
            <div id="id1"></div>        
      </body>
    </html>
    

    id1 should be overflowed but it isn't. I have set all the important div's "overflow" property to "visible" (even if it is the default). I don't know what I'm doing wrong.