Mic*_*ers 5 html css validation iframe
我不明白 HTML 5。验证器说:
iframe 元素上的 marginwidth 属性已过时。请改用 CSS。
iframe 元素上的 marginheight 属性已过时。请改用 CSS。
但根据这个接受的答案:
无法在样式表中设置 iframe 的 marginheight、marginwidth 和 frameborder 属性。
为什么他们要求我做一些不可能的事情?
要么把有效的东西放在规范中,要么想出一个真正的替代方案。他们似乎已经弃用了某些东西,并且他们的替代方案不起作用。
我在这里缺少什么?
HTML5 规范确实描述了marginheight 和 marginwidth 属性的工作原理。它说的是:
对于下表中的每个属性,给定一个 body 元素,存在的第一个属性映射到 body 元素上的像素长度属性。如果未找到属性的任何属性,或者无法成功解析找到的属性值,则预计该属性将使用默认值 8px。
Run Code Online (Sandbox Code Playgroud)Property Source 'margin-top' body element's marginheight attribute The body element's container frame element's marginheight attribute body element's topmargin attribute 'margin-right' body element's marginwidth attribute The body element's container frame element's marginwidth attribute body element's rightmargin attribute 'margin-bottom' body element's marginheight attribute The body element's container frame element's marginheight attribute body element's bottommargin attribute 'margin-left' body element's marginwidth attribute The body element's container frame element's marginwidth attribute body element's leftmargin attribute如果 body 元素的 Document 浏览上下文是嵌套浏览上下文,并且该嵌套浏览上下文的浏览上下文容器是frame 或 iframe 元素,则 body 元素的容器frame 元素就是该frame 或iframe 元素。否则,就没有容器框架元素。
因此,要达到相同的效果,您必须在所包含页面的 body 元素上设置 CSS 边距值,而不是在 iframe 元素上设置 CSS 边距值。
该规范随后解释了为什么浏览器可能不(甚至不应该)支持 marginwidth 和 marginheight :
警告!上述要求意味着页面可以使用 iframe 等方式更改另一页面(包括来自其他来源的页面)的边距。这存在潜在的安全风险,因为在某些情况下,它可能允许攻击造成页面呈现不符合作者预期的情况,可能是出于网络钓鱼或以其他方式误导用户的目的。
| 归档时间: |
|
| 查看次数: |
2424 次 |
| 最近记录: |