题目要求:
一、
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表格制作</title>
</head>
<body>
<table border="1" height="15%" width="60%" align="center">
<tbody>
<tr>
<td colspan="2" bgcolor="red" align="center">1</td>
<td align="center">2</td>
<td align="center">3</td>
</tr>
<tr>
<td rowspan="2" bgcolor="green" align="center">4</td>
<td align="center">5</td>
<td rowspan="3" bgcolor="pink" align="center">6</td>
<td rowspan="2" bgcolor="skyblue" align="center">7</td>
</tr>
<tr>
<td align="center">8</td>
</tr>
<tr>
<td align="center">9</td>
<td align="center">10</td>
<td align="center">11</td>
</tr>
</tbody>
</table>
</body>
</html>
网页效果:
二、
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表单设计</title>
</head>
<body>
<form>
<table>
<tr>
<td> 姓名:</td>
<td>
<input type="text" id="name" value="" size="20">
</td>
</tr>
<tr>
<td>性别:</td>
<td>
<input type="radio" name="sex" value="男">男
<input type="radio" name="sex" value="女">女
</td>
</tr>
<tr>
<td>籍贯:</td>
<td>
<select name="home">
<option id="default" selected="selected">
济南
</option>
<option id="jianing">济宁</option>
<option id="zaozhaung">枣庄</option>
<option id="rizhao">日照</option>
<option id="jinan">济南</option>
</select>
</td>
</tr>
<tr>
<td>爱好:</td>
<td>
<input type="checkbox">音乐
<input type="checkbox">体育
<input type="checkbox">美术
</td>
</tr>
<tr>
<td>备注:</td>
<td>
<textarea cols="30%" rows="15%"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="提交">
<input type="reset" value="取消" >
</td>
</tr>
</table>
<table>
</form>
</body>
</html>
三、
(要注意发送按钮与重写按钮的功能实现)
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表单二</title>
</head>
<body>
<form>
<table>
<tr>
<td>名字:
<input type="text" >
</td>
</tr>
<tr>
<td>E-mail:
<input type="text">
</td>
</tr>
<tr>
<td>
<textarea rows="5" cols="50"></textarea>
</td>
</tr>
<tr>
<td>
<input type="submit" value="发送留言">
<input type="reset" value="重写留言">
</td>
</tr>
</table>
</form>
</body>
</html>
网页效果:
四、
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表单三</title>
</head>
<body>
<form >
<table>
<caption>请选择您的择友条件</caption>
<tr>
<td>性别:</td>
<td>
<input type="radio" name="sex">男
<input type="radio" name="sex">女
<input type="radio" name="sex">不限
</td>
</tr>
<tr>
<td>年纪:</td>
<td>
<select>
<option>21~25</option>
<option>26~30</option>
<option>31~35</option>
</select>
</td>
</tr>
<tr>
<td>居住地区:</td>
<td>
<select>
<option>北京</option>
<option>上海</option>
<option>深圳</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" name="1" value="送出选择">
</td>
</tr>
</table>
</form>
</body>
</html>
网页效果:
五、
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>css1</title>
<style type="text/css">
.box{
position: absolute;
width: 500px;
height: 400px;
border:1px solid #000;
}
.shangbian{
background-color:#33FF33;
position: absolute;
width: 500px;
height: 70px;
}
.denglukou{
background-color:#DDDDDD;
position: absolute;
top: 70px;
width: 125px;
height: 50px;
}
.tongji1{
background-color:#99FF99;
position: absolute;
top: 120px;
width:125px;
height: 70px;
}
.tongji2{
position: absolute;
width:125px;
top: 190px;
height: 80px;
}
.tongji3{
position: absolute;
top: 270px;
width: 125px;
height: 80px;
background-color:#FAF0E6 ;
}
.xiamian{
background-color:#5500DD;
position: absolute;
top: 350px;
height: 50px;
width: 500px;
}
.center{
position: absolute;
top: 70px;
left: 125px;
height: 280px;
width: 375px;
background-color:#D0D0D0;
}
p {
position:absolute;
top: 50%;
left: 50%;
width: 80px;
height: 20px;
margin-top:-10px;
margin-left:-40px;
background-color: white;
}
</style>
</head>
<body>
<div class="box">
<div class="shangbian">
<p align="center">上边</p>
</div>
<div class="denglukou">
<p align="center">登录口</p>
</div>
<div class="tongji1">
<p align="center">统计</p>
</div>
<div class="tongji2">
<p align="center">统计</p>
</div>
<div class="tongji3">
<p align="center">统计</p>
</div>
<div class="xiamian">
<p align="center">下面区域</p>
</div>
<div class="center">
<p align="center">中间部分</p>
</div>
</div>
</body>
</html>
网页效果:(颜色略有差别)
六、
源代码:
(对标签p设置外边距来保证标签处于div层的中间)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>css1</title>
<style type="text/css">
.box{
position: absolute;
width: 500px;
height: 400px;
border:1px solid #000;
}
.shangbian{
background-color:#33FF33;
position: absolute;
width: 500px;
height: 70px;
}
.denglukou{
background-color:#DDDDDD;
position: absolute;
top: 70px;
width: 125px;
height: 50px;
}
.tongji1{
background-color:#99FF99;
position: absolute;
top: 120px;
width:125px;
height: 70px;
}
.tongji2{
position: absolute;
width:125px;
top: 190px;
height: 80px;
}
.tongji3{
position: absolute;
top: 270px;
width: 125px;
height: 80px;
background-color:#FAF0E6 ;
}
.xiamian{
background-color:#5500DD;
position: absolute;
top: 350px;
height: 50px;
width: 500px;
}
.center{
position: absolute;
top: 70px;
left: 125px;
height: 280px;
width: 375px;
background-color:#D0D0D0;
}
p {
position:absolute;
top: 50%;
left: 50%;
width: 80px;
height: 20px;
margin-top:-10px;
margin-left:-40px;
background-color: white;
}
</style>
</head>
<body>
<div class="box">
<div class="shangbian">
<p align="center">上边</p>
</div>
<div class="denglukou">
<p align="center">登录口</p>
</div>
<div class="tongji1">
<p align="center">统计</p>
</div>
<div class="tongji2">
<p align="center">统计</p>
</div>
<div class="tongji3">
<p align="center">统计</p>
</div>
<div class="xiamian">
<p align="center">下面区域</p>
</div>
<div class="center">
<p align="center">中间部分</p>
</div>
</div>
</body>
</html>
网页效果:
七、
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>css2</title>
<style type="text/css">
.box{
position:absolute;
border:1px solid blue;
}
.shang{
position:absolute;
width:800px;
height:100px;
background-color:#00FFFF;
border: 1px solid blue;
}
.left{
position:absolute;
width:250px;
height:500px;
top:100px;
background-color:#ffffff;
border: 1px solid blue;
}
.loign{
position: absolute;
top: 110px;
height: 120px;
width: 230px;
left: 7px;
background-color: #FFFF77;
border: 2px solid #00FF00;
}
.center{
position:absolute;
width:550px;
height:500px;
top:100px;
left:250px;
background-color:#00FF00;
border: 1px solid blue;
}
</style>
</head>
<body>
<div class="box">
<div class="shang"></div>
<div class="left"></div>
<div class="loign">
<form>
<table>
<tr>
<td>
用户名:
</td>
<td>
<input type="">
</td>
</tr>
<tr>
<td>
密码:
</td>
<td>
<input type="">
</td>
</tr>
<tr>
<td align="right"><input type="submit" value="提交" ></td>
<td align="center"><input type="reset" value="重置" ></td>
</tr>
</table>
</form>
</div>
<div class="center">
<p>此处显示Div标签的内容</p>
</div>
</div>
</body>
</html>
网页效果:
八、
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>css3</title>
<style type="text/css">
.top{
position: absolute;
width: 500px;
height: 100px;
background-color:#0066FF;
}
.left{
position:absolute;
top:100px;
width: 125px;
height: 450px;
border: 1px solid #0066FF;
}
.up{
position: absolute;
top:120px;
left:20px;
width: 100px;
height: 60px;
text-align:center;
border: 1px solid #0066FF;
}
.center{
position: absolute;
top: 108px;
height: 442px;
left:133px;
width: 372px;
background-color:#FFFFBB;
border:1px solid #000;
}
.bottom{
position: absolute;
top: 550px;
width: 500px;
height: 30px;
background-color: #0066FF;
}
</style>
</head>
<body>
<div class="top"></div>
<div class="left"></div>
<div class="up">登录区域</div>
<div class="center">此处显示新div标签的内容</div>
<div class="bottom"></div>
</body>
</html>
网页效果:
九、(注意实现文字在div层中的位置)
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>矩阵布局</title>
<style type="text/css">
.box{
position: absolute;
width: 380px;
height: 230px;
border: 2px solid #000;
}
.one{
position: absolute;
top: 20px;
left:20px;
width: 100px;
height: 50px;
border: 2px solid #000;
}
.two{
position: absolute;
top: 20px;
left: 140px;
width: 100px;
height: 50px;
border: 2px solid #000;
}
.three{
position: absolute;
top: 20px;
right:20px;
width: 100px;
height:50px;
border: 2px solid #000;
}
.four{
position: absolute;
top: 90px;
left: 20px;
width: 100px;
height: 50px;
border:2px solid #000;
}
.five{
position: absolute;
top: 90px;
left: 140px;
width: 100px;
height: 50px;
border: 2px solid #000;
}
.six{
position: absolute;
top: 90px;
right: 20px;
width: 100px;
height: 50px;
border:2px solid #000;
}
.seven{
position: absolute;
top: 160px;
left: 20px;
width: 100px;
height: 50px;
border: 2px solid #000;
}
.eight{
position: absolute;
top: 160px;
left:140px;
width: 100px;
height: 50px;
border: 2px solid #000;
}
.nine{
position: absolute;
top: 160px;
right: 20px;
width: 100px;
height: 50px;
border:2px solid #000;
}
div {
text-align: center;
line-height: 50px;
}
</style>
</head>
<body>
<div class="box">
<div class="one">1</div>
<div class="two">2</div>
<div class="three">3</div>
<div class="four">4</div>
<div class="five">5</div>
<div class="six">6</div>
<div class="seven">7</div>
<div class="eight">8</div>
<div class="nine">9</div>
</div>
</body>
</html>
网页效果:
十、
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>矩形布局2</title>
<style type="text/css">
.box{
position: absolute;
width: 740px;
height: 430px;
border:2px solid #000;
}
.one{
position: absolute;
top: 10px;
left: 10px;
width: 200px;
height: 100px;
border:2px solid #000;
line-height:100px;
}
.two{
position: absolute;
top: 10px;
left: 220px;
width: 100px;
height: 300px;
border:2px solid #000;
line-height:300px;
}
.three{
position: absolute;
top: 10px;
left:330px;
width: 300px;
height: 100px;
border:2px solid #000;
line-height:100px;
}
.four{
position: absolute;
top: 120px;
left:330px;
width: 400px;
height: 100px;
border:2px solid #000;
line-height:100px;
}
.five{
position: absolute;
top: 320px;
left: 10px;
width: 300px;
height: 100px;
border:2px solid #000;
line-height:100px;
}
.six{
position: absolute;
top: 320px;
left: 320px;
width: 400px;
height: 100px;
border:2px solid #000;
line-height: 100px;
}
div {
text-align: center;
}
</style>
</head>
<body>
<div class="box">
<div class="one">1</div>
<div class="two">2</div>
<div class="three">3</div>
<div class="four">4</div>
<div class="five">5</div>
<div class="six">6</div>
</div>
</body>
</html>
网页效果:
十一、
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>css5</title>
<style type="text/css">
.box{
position: absolute;
width: 600px;
height: 200px;
border-style: solid;
border-color: #000;
border-width: 2px;
}
.one{
float: left;
margin-top: 10px;
margin-left: 10px;
width: 150px;
height: 50px;
border:2px solid #000;
}
.two{
float: left;
margin-top: 10px;
margin-left: 10px;
width: 150px;
height: 50px;
border:2px solid #000;
}
.three{
float: right;
margin-top: 10px;
margin-right: 10px;
width: 150px;
height: 50px;
border:2px solid #000;
}
.four{
float: left;
margin-top: 10px;
margin-left: 10px;
width: 150px;
height: 50px;
border:2px solid #000;
}
.five{
float: right;
margin-top: 10px;
margin-right: 10px;
width: 150px;
height: 50px;
border:2px solid #000;
}
.six{
float: left;
margin-top: 10px;
margin-left: 10px;
width: 150px;
height: 50px;
border:2px solid #000;
}
.seven{
float: right;
margin-top: 10px;
margin-right: 10px;
width: 150px;
height: 50px;
border:2px solid #000;
}
.eight{
float: left;
margin-top: 10px;
margin-left: 10px;
width: 150px;
height: 50px;
border:2px solid #000;
}
.nine{
float: left;
margin-top: 10px;
margin-left: 10px;
width: 150px;
height: 50px;
border:2px solid #000;
}
div {
line-height: 50px;
text-align: center;
}
</style>
</head>
<body>
<div class="box">
<div class="one">1</div>
<div class="two">2</div>
<div class="three">3</div>
<div class="four">4</div>
<div class="five">5</div>
<div class="six">6</div>
<div class="seven">7</div>
<div class="eight">8</div>
<div class="nine">9</div>
</div>
</body>
</html>
网页效果:
十二、
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>js1</title>
<script language="javascript">
function checklogin(){
var user=document.getElementsByName("username")[0].value;
var pass=document.getElementsByName("password")[0].value;
if(user==""){
alert("请输入用户名");
return false;
}
else if(pass==""){
alert("请输入密码");
return false;
}
else{
alert("提交成功!");
return true;
}
}
</script>
<style type="text/css">
div {
width: 300px;
height: 100px;
text-align: center;
border:2px solid #33CCFF;
}
</style>
</head>
<body>
<div>
<form>
<table>
<tr>
<td>管理员用户名:</td>
<td><input type="text" name="username"><br></td>
</tr>
<tr>
<td>管理员密码:</td>
<td><input type="text" name="password"></td>
</tr>
<tr>
<td>
<input type="button" value="提交" onclick="checklogin()"/>
</td>
<td>
<input type="reset" value="重置" >
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
注意:
- js函数中的"username",“password"要对应相应的文本框,将其对应文本框的name属性修改为"username"或"password”,这样才可以实现弹窗功能。
- 按钮一定要定义在表单(form)中才可以发挥他的功能。
- 表单按钮(submit,reset,button)中的普通按钮(button),常用来响应js事件:比如onclick,用来调用js函数来实现各种功能。
网页效果:
十三、
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>js2</title>
<script language="javascript">
function checkarticle(){
var a=document.getElementsByName("author")[0].value;
var b=document.getElementsByName("title")[0].value;
var c=document.getElementsByName("content")[0].value;
if(a==""){
alert("请输入作者");
return false;
}
else if(b==""){
alert("请输入标题");
return false;
}
else if(c==""){
alert("请输入内容");
return false;
}
else{
alert("提交成功!");
return true;
}
}
</script>
<style type="text/css">
.box{
position: absolute;
top: 20px;
width: 500px;
height: 600px;
border:1px solid blue;
}
</style>
</head>
<body>
<div class="box">
<form>
<table>
<tr>
<td>文章题目:</td>
<td>
<input type="text" name="title">
</td>
</tr>
<tr>
<td>文章作者:</td>
<td>
<input type="text" name="author">
</td>
</tr>
<tr>
<td>文章内容:</td>
<td>
<textarea rows="30" cols="50" name="content"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" value="发送" onclick="checkarticle()"/>
<input type="reset" value="重写">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
网页效果:
整体布局↓