Categories: HTML教程

HTML 框架【iframe】

本节课,我们学习下HTML 框架【iframe】。

通过使用框架,你可以在同一个浏览器窗口中显示不止一个页面。

iframe语法

<iframe src="URL"></iframe>

该URL指向不同的网页。

iframe – 设置高度与宽度

height 和 width 属性用来定义iframe标签的高度与宽度。

属性默认以像素为单位, 但是你可以指定其按比例显示 (如:”80%”)。

<iframe loading="lazy" src="demo_iframe.htm" width="200" height="200"></iframe>

iframe – 移除边框

frameborder 属性用于定义iframe表示是否显示边框。

设置属性值为 “0” 移除iframe的边框:

<iframe src="demo_iframe.htm" frameborder="0"></iframe>

使用 iframe 来显示目标链接页面

iframe 可以显示一个目标链接的页面

目标链接的属性必须使用 iframe 的属性,如下实例:

<iframe src="demo_iframe.htm" name="iframe_a"></iframe>
<p><a href="https://www.web176.com" target="iframe_a" rel="noopener">Web176教程</a></p>

DEMO演示:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Web176教程(web176.com)</title> 
</head> 
<body>

<iframe src="demo_iframe.htm" name="iframe_a"></iframe>
<p><a href="https://www.web176.com" target="iframe_a">Web176教程</a></p>

<p><b>注意:</b> 因为 a 标签的 target 属性是名为 iframe_a 的 iframe 框架,所以在点击链接时页面会显示在 iframe框架中。</p>

</body>
</html>

HTML iframe 标签

标签说明
<iframe>定义一个内联的iframe
terry

这个人很懒,什么都没有留下~

Share
Published by
terry

Recent Posts

自定义指令:聊聊vue中的自定义指令应用法则

今天我们来聊聊vue中的自定义…

5 天 ago

聊聊Vue中@click.stop和@click.prevent

一起来学下聊聊Vue中@cli…

2 周 ago

Nginx 基本操作:启动、停止、重启命令。

我们来学习Nginx基础操作:…

2 周 ago

Vue3:手动清理keep-alive组件缓存的方法

Vue3中手动清理keep-a…

3 周 ago

聊聊React和Vue组件更新的实现及区别

React 和 Vue 都是当…

3 周 ago