How can you create an iframe as if it were a div? (fixed position)

I had it div

containing a bunch of tags with the appropriate css, all of which need to be moved to an iframe. However, when I do this, the iframe version looks different.

I already copied the css that was applied to those parts of the parent page in the stylesheet for the iframe. However, when styling the border, div -> iframe

it is not clear what styles should be applied to the body

iframe tag , and what styles should be applied by the tag iframe

on the parent page.

+3


source to share


1 answer


You just need to give both elements the same style.

Html

<iframe src="http://example.com" frameborder="0"></iframe>
<div></div>

      

Note. The attribute is frameborder

required for IE <9 to avoid the ugly 3D border.



CSS

iframe,div {
    width: 450px;
    height: 250px;
    border: 1px solid #ccc;
    display: block;

    padding: 0;
    margin: 10px 20px;
}

      

Here's a script containing this code .

+3


source







All Articles