gpt4 book ai didi

html - 没有属性 "allowtransparency"

转载 作者:技术小花猫 更新时间:2023-10-29 11:40:29 25 4
gpt4 key购买 nike

我正在寻找一些替代方法:

<iframe transparency=true   ...

当我进行 W3C 验证时,出现错误:

Column 31: there is no attribute "allowtransparency"

如果使用这个 CSS,

.iframe-trans-fix{
opacity: 0;
filter:alpha(opacity=0);
}

对于上面的代码片段,我得到一个空白的 iframe。

最佳答案

虽然 W3C 的 HTML 规范确实没有定义它,但有一个 allowTransparency 属性,并且所有现代浏览器(和 Internet Explorer)都支持它。作为HTML5告诉我们,本末倒置。

假设您的主页上有这个 HTML,index.html:

<html>
<body>
<iframe src="source.html"
allowTransparency="true"
style="background-color:lightgreen;"
width="400" height="200">
</iframe>
</body>
</html>

你的 source.html 看起来像这样:

<html>
<body>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin gravida, magna
id bibendum sollicitudin, tellus tortor consequat enim, et mollis mauris
augue et dui. </p>
</body>
</html>

当您在浏览器中打开主页 (index.html) 时,您会在 iframe 中看到来自 source.html 的文本,但它的背景为浅绿色。

(在 Mac OS X 上使用 Safari、Firefox 和 Chrome 以及在 Windows XP 上使用 Internet Explorer 8 和 Chrome 进行测试)

编辑:关键是:源页面不能设置自己的背景。如果是,它会忽略透明背景。

更新:刚刚在 macOS High Sierra 上使用 Safari 12、Chrome 73 和 Firefox 65 对此进行了测试(2019 年 3 月),它仍然有效。

关于html - 没有属性 "allowtransparency",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3740700/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com