CSS/HTML5 equivilent to iframe marginheight and marginwidth

后端 未结 3 1553
暖寄归人
暖寄归人 2021-01-18 01:32

I am doing a website layout for a company who uses IDevAdManager for rotating ads on their site. Unfortunately, I am not much of an expert in that field, so I can\'t give m

3条回答
  •  孤独总比滥情好
    2021-01-18 01:44

    To be HTML5 valid the document inside the iframe has to get the correct style, not the iframe itself. I don't know that adManager thing but it depends on how the iframe is created.

    If it is dynamic and sameorigin you can enter it by

    document.getElementById("SomeIframe").contentDocument;
    

    and set margin by style to 0.

    let myFrameBody = document.getElementById("SomeIframe").contentDocument.querySelector('body');
    myFrameBody.style.margin = 0;
    

    If it is not sameorigin the owner of the document has to set this by himself, and that is never a bad idea, and also regarding HTML4.1 this would be considered valid.

提交回复
热议问题