XZ_HTML之HTML框架和 HTML内联框架 iframe

来源:互联网 发布:广联达预算软件使用 编辑:程序博客网 时间:2024/05/22 01:54
水平框架
<frameset rows="25%,50%,25%">
      <frame src="First.html"/>
  <frame src="Second.html"/>
  <frame src="index.html"/>
</frameset>
框架结构标签<frameset>
• 框架结构标签(<frameset>)定义如何将窗口分割为框架
• 每个 frameset 定义了一系列行
• rows/columns 的值规定了每行或每列占据屏幕的面积
框架标签(Frame)
Frame 标签定义了放置在每个框架中的 HTML 文档。
垂直框架
在下面的这个例子中,我们设置了一个两列的框架集。第一列被设置为占据浏览器窗口的 25%。第二列被设置为占据浏览器窗口的 75%。HTML 文档 First.html" 被置于第一个列中,而 HTML 文档 "Second.html" 被置于第二个列中:
 <frameset cols="25%,75%">
  <frame src="First.html"/>
  <frame src="Second.html"/>
</frameset>
注意:
1>假如一个框架有可见边框,用户可以拖动边框来改变它的大小。为了避免这种情况发生,可以在 <frame> 标签中加入:noresize=“noresize"。
2>为不支持框架的浏览器添加 <noframes> 标签。
3>不能将 <body></body> 标签与 <frameset></frameset> 标签同时使用!不过,假如你添加包含一段文本的 <noframes> 标签,就必须将这段文字嵌套于 <body></body> 标签内。
含有noresize=“noresize"属性的框架标签:
 
框架是不可调整尺寸的。在框架间的边框上拖动鼠标,你会发现边框是无法移动的。
<frame src="index.html"noresize="noresize"/>
如何使用<noframes>标签:
<frameset rows="25%,50%,25%">
     <frame src="First.html"/>
  <frame src="Second.html"/>
  <frame src="index.html"/>
  <noframes>
      <body>您的浏览器无法处理框架。</body>
  </noframes>
</frameset>
混合框架标签:
<frameset rows="50%,50%">
    <frame src="First.html"/>
    <frameset cols="25%,25%">
        <frame src="index.html" />
        <frame src="Second.html" />
    
</frameset>
</frameset>
导航框架
导航框架包含一个将第二个框架作为目标的链接列表。名为 "contents.htm" 的文件包含三个链接。
<frameset cols="120,*">
  <frame src="/example/html/html_contents.html">
  <frame src="/example/html/frame_a.html"name="showframe">
</frameset>
效果图:点击左侧,可以在右侧看到框架 


内联框架
<body>
    <iframe src="img/康乃馨.jpg"></iframe>
</body>
跳转至框架内的一个指定的节
其中的一个框架设置了指向另一个文件内指定的节的链接。这个"link.htm"文件内指定的节使用 <a name="C10"> 进行标识。
<frameset cols="20%,80%">
    <frame src="First.html"/>
    <frame src="Second.html#C10"/>
</frameset>
使用框架导航跳转至指定的节
左侧的导航框架包含了一个链接列表,这些链接将第二个框架作为目标。第二个框架显示被链接的文档。导航框架其中的链接指向目标文件中指定的节。
<frameset cols="180,*">
    <frame src="First.html">
    <frame src="Second.html"name="showframe">
</frameset
效果图



HTML内联框架 Iframe
用于在网页内显示网页
iframe 元素会创建包含另外一个文档的内联框架(即行内框架)。
您可以把需要的文本放置在 <iframe> 和 </iframe> 之间,这样就可以应对无法理解 iframe 的浏览器。
语法
<iframe src="url"></iframe>
URL 指向隔离页面的位置。
Iframe - 设置高度和宽度
height 和 width 属性用于规定 iframe 的高度和宽度。
属性值的默认单位是像素,但也可以用百分比来设定(比如 “80%”)。
<iframe src="First.html"width="500"height=“300”></iframe>
Iframe - 删除边框
frameborder 属性规定是否显示 iframe 周围的边框。
设置属性值为 "0" 就可以移除边框:
<iframe src="First.html"width="500"height="300"frameborder=“0">
</
iframe>
使用 iframe 作为链接的目标
iframe 可用作链接的目标(target)。
链接的 target 属性必须引用 iframe 的 name 属性:
<iframe src="First.html"name="iframe_a"width="600"height=“140"> </iframe>
<p><ahref="http://www.baidu.com"target="iframe_a">BaiDu</a></p>
效果:
点击链接之前 


点击链接之后




0 0
原创粉丝点击