【问题标题】:Unable to change the styling properties inside an iframe body tag无法更改 iframe 正文标记内的样式属性
【发布时间】:2020-12-31 05:15:10
【问题描述】:

我已经编写了这个 html 脚本来在 iframe 中显示维基百科,但我想更改它的背景颜色,下面是我尝试过的代码 sn-p。但它不起作用。

<!DOCTYPE html> 

<html> 

<head> 
<style>

    body {
        background-color: blue !important;
       /* Adding !important will give this rule more precedence over inline style */
    }



</style>

  

</head> 

<body> 

<iframe style="background-color:#fc3 !important;" src="https://www.wikipedia.org/" width="100%" height="450px" > 
</iframe>
 
</body> 

</html> 

【问题讨论】:

  • 你写错了。在 iframe 中查看背景颜色

标签: javascript html css iframe styles


【解决方案1】:

您无法在加载(使用 CSS)之前修改 iframe 的内容,因为它正在显示来自另一个页面的内容。加载后,您可以使用javascript对其进行修改。

【讨论】:

  • 嗨,Ian,我可以知道如何用 javascript 修改它。你有示例代码吗?
猜你喜欢
  • 1970-01-01
  • 2011-01-01
  • 1970-01-01
  • 2013-03-11
  • 1970-01-01
  • 2017-05-06
  • 2023-04-01
相关资源
最近更新 更多