【任务5-1】使用表格布局页面
【任务描述】
(1)创建外部样式文件0501global.css,在该样式文件中定义必要的CSS样式。
(2)创建外部样式文件05user.css,在该样式文件中定义必要的CSS样式。
(3)创建网页文档0501.html,该网页主体结构主要应用Div CSS进行布局,局部结构应用了表格和段落进行布局。网页0501.html还应用了CSS样式对表格、单元格、表单控件和超链接进行美化。
【任务实施】
1.创建外部样式文件0501global.css
创建外部样式文件0501global.css,保存在文件夹“5-1css”中,在该样式文件中定义必要的CSS样式。
源代码如下:
body { font-family: "Trebuchet MS", Arial, Helvetica, "sans-serif,宋体"; font-size: 12px; } a { text-decoration: none; color:#333; } a:hover { text-decoration: underline; color:#c00; } img { border: none; } |
2.创建外部样式文件05user.css
创建外部样式文件05user.css,保存在文件夹“5-1css”中,在该样式文件中定义必要的CSS样式。
源代码如下:
#user_wrapper { margin:10px auto; width:990px; overflow:hidden; } #steptitle { background:url("../images/bg_sl.gif"); height:41px; line-height:41px; padding-left:10px; font-size:18px; font-family:"微软雅黑", "microsoft yahei", "microsoft jhenghei"; font-weight:normal; text-align: center; } #stepcontent1column { margin:0px auto; width:990px; } #stepcontent1column table { *border-collapse:collapse; border-spacing:0; line-height:1.8; } #stepcontent1column .table_b { width:100%; margin-bottom:0px; border-left:1px solid #ccc; border-bottom:1px solid #ccc; } #stepcontent1column .table_b td, #stepcontent1column .table_b th { border-top:1px solid #ccc; border-right:1px solid #ccc; padding:5px; font-size:12px; background:#f2f2f2; } #stepcontent1column .table_b td { height:21px; line-height:150%; } #stepcontent1column .fred { color:#f00; } #stepcontent1column .table_b td .btn1 { background:url("../images/05bt.gif") no-repeat; width:62px; height:23px; display:block; color:#000; white-space:nowrap; margin:0 0 0 1px; } #stepcontent1column .shopbtn { text-align:center; clear:both; } #shopmsg { background:url("../images/bg_sl.gif"); padding: 10px 20px; } |
3.创建网页文档0501.html
创建网页文档0501.html,保存在文件夹“5-1”中,该网页主体结构主要应用了Div CSS进行布局,局部结构应用了表格和段落进行布局,该网页主体布局结构的HTML代码如下所示。还应用了CSS样式对表格、单元格、表单控件和超链接进行美化。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="https://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>易购网-我的购物车</title> <link rel="stylesheet" href="css/0501global.css" type="text/css" media="screen" /> <link rel="stylesheet" href="css/05user.css" type="text/css" media="screen" /> </head> <body>
<div id="user_wrapper"> <div id="steptitle"><strong>我的购物车</strong></div> <div id="stepcontent1column"> <table class="table_b"> <tbody> <tr> <th align="middle" width="11%"><strong>商品图片</strong></th> <th align="middle" width="35%"><strong>商品名称</strong></th> <th align="middle" width="12%"><strong>优惠价</strong></th> <th align="middle" width="9%"><strong>数 量</strong></th> <th align="middle" width="12%"><strong>小计金额</strong></th> <th align="middle" width="12%"><strong>税后金额</strong></th> <th align="middle" width="20%"><strong>操作</strong></th> </tr> <tr> <td align="middle"> <a href="#" target="_blank"><img src="images/20100501.jpg" alt="商品图片" width="80" height="60" /></a> </td> <td> <a href="#" target="_blank">惠普(hp)10.1英寸led屏笔记本电脑</a> </td> <td class="fred" align="middle"><strong>¥3388.00</strong></td> <td align="middle"> <input name="shopcartlist11" id="shopcartlist11" value="1" size="5" /> </td> <td class="fred" align="middle"><strong>¥3388.00 </strong></td> <td class="fred" align="middle"><strong>¥3388.00</strong></td> <td class="fred" align="middle"><strong><a class="btn1">删 除</a></strong> </td> </tr> <tr> <td align="middle"> <a href="#" target="_blank"><img src="images/20100502.jpg" alt="商品图片" width="80" height="60" /></a> </td> <td> <a href="#" target="_blank">苹果apple ipod nano 五代 8gb 2.0英寸 紫色 带摄像头</a></td> <td class="fred" align="middle"><strong>¥999.00</strong></td> <td align="middle"> <input name="shopcartlist12" id="shopcartlist12" value="1" size="5" /> </td> <td class="fred" align="middle"><strong>¥999.00 </strong></td> <td class="fred" align="middle"><strong>¥3996.00</strong></td> <td class="fred" align="middle"><strong><a class="btn1">删 除</a></strong> </td> </tr> <tr> <td align="middle"> <a href="#" target="_blank"><img src="images/20100503.jpg" alt="商品图片" width="80" height="60" /></a> </td> <td> <a href="#" target="_blank">全新行货 惠普hp deskjet f2288 彩色打印复印扫描一体机</a></td> <td class="fred" align="middle"><strong>¥489.00</strong></td> <td align="middle"> <input name="shopcartlist13" id="shopcartlist13" value="1" size="5" /> </td> <td class="fred" align="middle"><strong>¥489.00 </strong></td> <td class="fred" align="middle"><strong>¥2934.00</strong></td> <td class="fred" align="middle"><strong><a class="btn1">删 除</a></strong> </td> </tr> </tbody> </table> <div id="shopmsg"> <p>商品总计:<span class="fred">3</span>件 商品总金额:<span class="fred">4876.00</span>元 税后金额:<span class="fred">4930.00</span>元 </p> <p style="float: left"> <input id="clearbtn" style="border-width:0px;" type="image" src="images/05shopbtn1.gif" name="clearbtn" /> <input id="updatebtn" style="border-width:0px;" type="image" src="images/05shopbtn2.gif" name="updatebtn" /> <a href="#"><img src="images/05shopbtn3.gif" /></a> </p> <p style="float: right"> <input id="nextbtn" style="border-width:0px; " type="image" src="images/05check_out.png" name="nextbtn" /> </p> <div class="shopbtn"></div> </div> </div> </div> </body> </html> |
4.保存网页与浏览网页效果
保存网页0501.html,然后按快捷键F12浏览该网页,其浏览效果如下图所示。
老师讲的太好了,学会了好多!
老师讲的很好,简单易懂
条理清晰,很好
老师讲得简单易懂,学习了很多东西。
这枯燥的课程能让老师讲解的如此生动,代码如此好记,给老师点个赞。
老师讲课很细致
讲课生动形象,容易理解,棒棒哒
老师讲的声情并茂,我收获很多
学到了很多东西,谢谢老师
非常好
老师棒棒哒
代码虽然很枯燥,但老师讲课很生动