How to make width and height of iframe same as its parent div?

前端 未结 3 1061
粉色の甜心
粉色の甜心 2020-12-16 11:22

I have a iframe inside a div. I want the size of iframe to be exactly the size of its parent div. I used following code to set the width and height of iframe.



        
3条回答
  •  一整个雨季
    2020-12-16 11:42

    you have a lot of typos.

    a correct markup should be like:

    
    

    also, if this frame already has an ID, why don't you put this in CSS like this (from a separate stylesheet file):

    #myIframe
    {
        position: relative;
        height: 100%;
        width: 100%; 
    }
    

    and HTML

    
    

    mind that scrolling & frameborder are iframe attribute, not style attribute.

提交回复
热议问题