如何在 HTML 中添加内联子窗口?
htmlweb developmentfront end technology更新于 2026/1/16 9:48:17
内联子窗口是一个 iframe,您可以使用 <iframe> 标签将其添加到 HTML 中。
HTML <iframe> 标签支持以下附加属性 −
| 属性 | 值 | 描述 |
|---|---|---|
| align | left right top middle bottom | 指定如何根据周围文本对齐 iframe。 |
| frameborder | 1 0 | 指定是否显示框架周围的边框。 |
| height | pixels | 指定内联框架的高度。 |
| longdesc | URL | 框架内容详细描述的 URL |
| marginheight | pixels | 允许您指定框架边框左右两侧与框架内容之间的间距。该值以像素为单位。例如,marginwidth = "10"。 |
| marginwidth | pixels | 指定框架内容与其左右边距之间的边距(以像素为单位)。 |
| name | text | Name of the frame |
| sandbox | "" allow-forms allow-same-origin allow-scripts allow-top-navigation | 为 iframe 中的内容启用一组额外的限制。 |
| scrolling | yes no auto | 确定滚动条操作 |
| seamless | seamless | 指定 iframe 应该看起来像是包含文档的一部分 |
| src | URL | 框架内容文件的位置 |
| srcdoc | HTML_code | 规定要在 iframe 中显示的页面 HTML 内容 |
width | pixels | 指定内联框架的宽度。 |
示例
您可以尝试运行以下代码来创建内联框架 −
<!DOCTYPE html> <html> <head> <title>HTML iframe Tag</title> </head> <body> <iframe src = "https://www.cainiaomax.com/index.htm" width = "100%"></iframe> </body> </html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

