1.iframe
Creating Web Pages Using Frames使用框架创建页面
Exploring the <IFRAME> Tag 探索<IFRAME>标签
<!DOCTYPE HTML>
<HTML>
<BODY>
<IFRAME name="HeaderFrame" width="91%" height="100" ></IFRAME>
<IFRAME name="NavigationFrame" width="25%" height="500"></IFRAME>
<IFRAME name="ContentFrame" width="65%" height="500" ></IFRAME>
</BODY>
</HTML>
In the preceding code, the <IFRAME> tag is used to divide the Web page, home.html, into frames of different width and height. Now, to make the Web pages visible inside the frames, you need to create, and then embed these Web pages inside the frames.
<!DOCTYPE HTML>
<HTML>
<HEAD>
<STYLE>
body{
background-color: #00C0F3;
}
ul{
margin: 0;
padding: 0;
list-style: none;// remove bullets from the unordered list
width: 350px;
}
ul li a {
display: block;
text-decoration: none;
color: Black;
background: #B3ECFC;
padding: 5px;
border: 1px solid #ccc;
border-bottom: 0;
}
ul {
margin: 0;
padding: 0;
list-style: none;
width: 320px;
}
li:hover ul {
display: block;
}
a:hover
{
background-color:#5E9DC9;
}
</STYLE>
</HEAD>
<BODY>
<UL>
<LI><A href="Courses.html">Courses</A></LI>
<LI><A href="Book1.html">MySQL5 Database Administrator Certified
Professional Exam Part- I</A></LI>
<LI><A href="Book2.html">MySQL5 Developer Certified Professional Exam Part I</A></LI>
<LI><A href="Book3.html">MySQL5 Developer Certified Professional Exam Part II</A></LI>
</UL>
</BODY>
</HTML>
Similarly, other Web pages can also be created by using the HTML code.
<!DOCTYPE HTML>
<HTML>
<BODY>
<IFRAME srcdoc= "<CENTER><H1><B>Learn MySQL</B></H1></CENTER> "name="HeaderFrame"width="91%" height="100" ></IFRAME>
<IFRAME src="nav.html" name="NavigationFrame" width="25%" height="500"> </IFRAME>
<IFRAME name="ContentFrame" width="65%" height="500" ></IFRAME>
</BODY>
</HTML>
In the preceding code, the file, header.html, is embedded inside the frame, HeaderFrame. Similarly, thefile, nav.html, is embedded in the frame named NavigationFrame. This is done by providing the name ofthe files as a value for the src attribute of the corresponding <IFRAME> tags used to create theframes.However, the content frame is not displaying anything as no HTML page has been specified for it.
在前面的代码中,文件 header.html 嵌入在框架 HeaderFrame 中。同样,文件 nav.html 嵌入在名为 NavigationFrame 的框架中。这是通过提供文件名作为用于创建帧的相应标记的 src 属性的值来完成<IFRAME>的。但是,内容框架不显示任何内容,因为没有为其指定 HTML 页面。
The home.html Web page of the LearnMySQL website is displayed, as shown in the following figure. 将显示 LearnMySQL 网站的首页.html网页,如下图所示。
<!DOCTYPE HTML>
<HTML>
<BODY>
<UL>
<LI><A href="Courses.html" target="ContentFrame">Courses</A></LI>
<LI><A href="Book1.html" target="ContentFrame">MySQL5 Database Administrator Certified Professional Exam Part- I</A></LI>
<LI><A href="Book2.html" target="ContentFrame">MySQL5 Developer Certified
Professional Exam Part- I</A></LI>
<LI><A href="Book3.html" target="ContentFrame">MySQL5 Developer Certified
Professional Exam Part- II</A></LI>
</UL>
</BODY>
</HTML>
In the preceding code snippet, the target attribute is used to specify ContentFrame as a target frame for the links. On clicking a link, the corresponding Web page is displayed inside the frame, ContentFrame, as shown in the following figure.
Styling Frames框架样式
<!DOCTYPE HTML>
<HTML>
<HEAD>
<STYLE>
iframe{
border :5px solid black;
margin-left :1px;
padding: 1px;
}
</STYLE>
</HEAD>
<--下方代码省略-->
</HTML>The preceding code snippet applies a black color border to the frames with the left margin of 1px. The output of the preceding code snippet is displayed in the following figure.