Html CSS 实操一
这个项目以12306网页为背景下设计的主要去理解Html Css 弹性布局 百分比布局 本页面分为八个小模块 这后各位可以自己去拼接:
写静态网页的过程中理解自己学过的内容
这里用到的内容都是前端入门”基础:Html Html5 Css Css3 具体的内容看下面的代码:
要素材的可以到官网去找:
第一模块 是如何实现的呢?
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>头部</title> <style> body { margin: 0px; padding: 0px; /* background-color: aliceblue; */ } #one { height: 80px; width: 100%; background-color: whitesmoke; } #one div { float: left; } #one1 { float: left; height: 100px; width: 40%; background-color: whitesmoke; } #one2 { height: 100px; width: 28%; background-color: whitesmoke; } #one3 { font-size: 18px; color: cornflowerblue; height: 100px; width: 31%; background-color: whitesmoke; display: flex; justify-content: space-around; text-align: center; line-height: 100px; font-weight: 900; } input { height: 40px; width: 60%; } #img1 { width: 65%; height: 100px; background-size: 12px; } .one3{ border-right:3px solid lightskyblue; } </style> </head> <body> <!-- 头部 --> <!-- 第一模块 --> <div id="one"> <div id="one1"> <p align="center"><img src="img/logo@2x.png" alt="" id="img1"></p> </div> <!-- <img src="img/link03.png" alt="" id="one1" width="20%"> --> <div id="one2"> <p align="center"><input type="text" placeholder="请输入车票餐饮制度" /></p> <!-- <img src="img/search.jpg" style="height: 40px;"/> --> </div> <div id="one3"> <span class="one3">English</span> <span class="one3">我的12306</span> <span>登录 注册</span> </div> </body> </html>
第二模块 导航栏如何制作?
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <style> #navs { height: 100%; } nav { line-height: 80px; width: 100%; height: 80px; flex-direction: row; display: flex; flex-direction: row; justify-content: space-around; position: sticky; } a { text-align: center; text-decoration: none; color: black; width: 12.5%; } a:hover { background-color: whitesmoke; font-weight: 800; color: black; border: 1px solid red; } nav.sticky { position: fixed; background-attachment: fixed; background-color: lightcyan; } </style> <!-- 第二模块 --> <div id="navs" class="sticky"> <!-- 导航栏 --> <nav class="sticky"> <a href="首页">首页</a> <a href="车票">车票</a> <a href="团购服务">团购服务</a> <a href="会员服务">会员服务</a> <a href="站车服务">站车服务</a> <a href="高铁服务">高铁服务</a> <a href="出行指南">出行指南</a> <a href="信息查询">信息查询</a> </nav> </div> </body> </html>
第三 模块动画如何实现的?
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>动画来回循环</title> <style> li { text-decoration: none; list-style: none; } .pics { position: relative; width: 100%; } .pic1 { width: 100%; -webkit-animation: picDraw 10s ease-in-out infinite; } .pic3 { position: absolute; width: 100%; top: 0; -webkit-animation: picDraw 10s ease-in-out infinite; } @keyframes picDraw { 0% { opacity: 0.25; transform: scale(0.5); } 25% { left: 10%; opacity: 0.5; transform: scale(0.7); } 50% { opacity: 0.75; transform: scale(0.8); } 0% { opacity: 0.9; transform: scale(1.2); } } </style> </head> <body> <div class="pics"> <img src="img/banner20200707.jpg" alt="" class="pic1"> <img src="img/banner12.jpg" alt="" class="pic3"> </div> </body> </html>
第四部分 精灵图的内容如何实现的呢?
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <style> #one { width: 200px; height: 80px; background: url(img/service@2x.png)64px -79px; background-repeat: no-repeat; } #two { width: 200px; height: 80px; background: url(img/service@2x.png)64px -392px; background-repeat: no-repeat; } #three { width: 200px; height: 87px; background: url(img/service@2x.png)64px -234px; background-repeat: no-repeat; } #four { width: 200px; height: 85px; background: url(img/service@2x.png)64px -312px; background-repeat: no-repeat; } #five { width: 200px; height: 85px; background: url(img/service@2x.png)64px -151px; background-repeat: no-repeat; } #six { width: 200px; height: 85px; background: url(img/service@2x.png)64px -476px; background-repeat: no-repeat; } #serven { width: 200px; height: 85px; background: url(img/service@2x.png)64px 20px; background-repeat: no-repeat; } /* 父 */ #father { width: 100%; height: 150px; float: left; display: flex; justify-content: space-around; } /* 子 */ .opuy { width: 200px; /* background-color: pink; */ } .lopu { font-weight: 900; font-size: 18px; text-align: center; position: relative; top: 99px; } </style> <div id="father"> <div class="opuy"> <div id="one"> <p class="lopu">重点旅游预约</p> </div> <!-- <p class="lopu">重点旅游预约</p> --> </div> <div class="opuy"> <div id="two"> <p class="lopu" id="b">遗失物品查找</p> </div> <!-- <p class="lopu">遗失物品查找</p> --> </div> <div class="opuy"> <div id="three"> <p class="lopu" id="c">开始约车服务</p> </div> <!-- <p class="lopu">开始约车服务</p> --> </div> <div class="opuy"> <div id="four"> <p class="lopu" id="d">开始便民拖运</p> </div> <!-- <p class="lopu">开始便民拖运</p> --> </div> <div class="opuy"> <div id="five"> <p class="lopu" id="e">进行车站引导</p> </div> <!-- <p class="lopu">进行车站引导</p> --> </div> <div class="opuy"> <div id="six"> <p class="lopu" id="f">战车等待时间</p> </div> <!-- <p class="lopu">战车等待时间</p> --> </div> <div class="opuy"> <div id="serven"> <p class="lopu" id="g">开始用户反馈</p> </div> <!-- <p class="lopu">开始用户反馈</p> --> </div> </div> </body> </html>
弹性布局的方式如何实现的
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <!-- 第五 --> <style> #father1 { height: 100%; width: 80%; position: absolute; display: flex; justify-content: space-around; /* border: 1px solid red; */ /* flex-wrap: wrap; */ left: 9.1%; } .sone { height: 120px; width: 230px; border: gainsboro 2px solid; /* background-color: antiquewhite; */ background-image: url("img/service04.jpg"); background-repeat: no-repeat; background-size: 250px; position: relative; padding: 2px; } p { position: absolute; font-weight: 900; font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; top: 150px; left: 0px; } span { position: absolute; font-size: 30px; font-weight: 900; color: orange; font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; top: 220px; left: 0px; } </style> <div id="father1"> <div class="sone"> <p>"环西部火车站 "高品质旅游版专程车</p> <span>¥2560</span> </div> <div class="sone"> <p>"环西部火车站 "高品质旅游版专程车</p> <span>¥2560</span> </div> <div class="sone"> <p>"环西部火车站 "高品质旅游版专程车</p> <span>¥2560</span> </div> <div class="sone"> <p>"环西部火车站 "高品质旅游版专程车</p> <span>¥2560</span> </div> <div class="sone"> <p>"环西部火车站 "高品质旅游版专程车</p> <span>¥2560</span> </div> </div> </body> </html>
不能使用弹性布局 如何实现
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <style> #img-four { /* background-color: #90bbe9; */ width: 1500px; height: 560px; } #hr { color: #5fa4ef; top: 678x; } span { height: 20px; width: 80%; border: 2px crimson red; } </style> <!-- 第四模块 --> <div id="img-four"> <div align="center"> <img src="img/abanner01.jpg" alt="" style="height: 240px;width:700px;padding: 20px;"> <img src="img/abanner02.jpg" alt="" style="height: 240px;width:700px;padding: 20px;"> <img src="img/abanner05.jpg" alt="" style="height: 240px;width:700px;padding: 20px;"> <img src="img/abanner06.jpg" alt="" style="height: 240px;width:700px;padding: 20px;"> </div> </div> </body> </html>
这样的布局如何实现
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <style> #father4 { height: 100px; /* border: 1px solid red; */ /* background-color: palevioletred; */ display: flex; justify-content: space-between; } #father4 div { text-align: center; line-height: 100px; font-weight: 800; background-color: palevioletred; color: red; height: 100px; width: 30%; /* border: 1px solid black; */ } #father4 div:hover { background-color: green; color: white; } td { font-size: 16px; font-weight: 400; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; width: 25%; opacity: 0.6; } span { border-radius: 12px; background-color: black; } </style> <div id="father4"> <!-- 我是father的盒子 --> <div>最新发布</div> <div>常看到的问题</div> <div>信用信息</div> </div> <!-- 表格 --> <table style="width: 100%;"> <tr> <td><span>*</span> 公告</td> <td>2022/10/7</td> <td><span>*</span> 公告</td> <td>2022/10/7</td> </tr> <tr> <td><span>*</span> 公告</td> <td>2022/10/7</td> <td><span>*</span> 公告</td> <td>2022/10/7</td> </tr> <tr> <td><span>*</span> 公告</td> <td>2022/10/7</td> <td><span>*</span> 公告</td> <td>2022/10/7</td> </tr> <tr> <td><span>*</span> 公告</td> <td>2022/10/7</td> <td><span>*</span> 公告</td> <td>2022/10/7</td> </tr> </table> </body> </html>
其实我想告诉各位的是 :
以任务为驱动去完成 一个页面 或者 一个项目 在任务中去学习自己要学的知识点
自已要用画整为零的思想,也要有画零为整的艺术。先完成部分在完成整体 然后开始组装
总结:看下面的图解自己组装上面的各个零件:
1 到 3 部分的效果图