Using CSS to affect div style inside iframe

前端 未结 13 1700
失恋的感觉
失恋的感觉 2020-11-22 07:00

Is it possible to change styles of a div that resides inside an iframe on the page using CSS only?

13条回答
  •  遥遥无期
    2020-11-22 07:25

    Yes. Take a look at this other thread for details: How to apply CSS to iframe?

    var cssLink = document.createElement("link");
    cssLink.href = "style.css";  
    cssLink.rel = "stylesheet";  
    cssLink.type = "text/css";  
    frames['frame1'].document.body.appendChild(cssLink); 
    

提交回复
热议问题