综合案例
案例1-学生信息管理
-
效果
-
源代码
-
效果
-
源代码
案例2-下拉菜单
-
效果
-
源代码
案例3-提示工具
-
效果
-
源代码
案例4-布局
-
效果
-
源代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CSS 网页布局</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> * { box-sizing: border-box; } body { margin: 0; } /* 头部样式 */ .header { background-color: #f1f1f1; padding: 20px; text-align: center; } /* 导航条 */ .topnav { overflow: hidden; background-color: #333; } /* 导航链接 */ .topnav a { float: left; display: block; color: #f2f2f2; text-align: center; padding: 14px 16px; text-decoration: none; } /* 链接 - 修改颜色 */ .topnav a:hover { background-color: #ddd; color: black; } /* 创建三个相等的列 */ .column { float: left; padding: 10px; } /* 左右两侧宽度 */ .column.side { width: 25%; } /* 中间区域宽度 */ .column.middle { width: 50%; } /* 列后面清除浮动 */ .row:after { content: ""; display: table; clear: both; } /* 响应式布局 - 宽度小于600px时设置上下布局 */ @media screen and (max-width: 600px) { .column.side, .column.middle { width: 100%; } } /* 底部样式 */ .footer { background-color: #f1f1f1; padding: 10px; text-align: center; } </style> </head> <body> <div class="header"> <h1>头部区域</h1> <p>重置浏览器大小查看效果。</p> </div> <div class="topnav"> <a href="#">链接</a> <a href="#">链接</a> <a href="#">链接</a> </div> <div class="row"> <div class="column side"> <h2>左侧栏</h2> <p>学的不仅是技术,更是梦想!</p> </div> <div class="column middle"> <h2>主区域内容</h2> <p>学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!</p> <p>学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!学的不仅是技术,更是梦想!</p> </div> <div class="column side"> <h2>右侧栏</h2> <p>学的不仅是技术,更是梦想!</p> </div> </div> <div class="footer"> <p>底部区域</p> </div> </body> </html>