批改狀態(tài):合格
老師批語(yǔ):使用flex之后, 你會(huì)發(fā)現(xiàn), 頁(yè)面中的標(biāo)簽嵌套少了很多, 并且很多標(biāo)簽都沒(méi)有原有的屬性, 被flex重新定義, 除了語(yǔ)義
仿m.php.cn自適應(yīng)移動(dòng)端頁(yè)面首頁(yè)
效果圖:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="static/css/style1.css"> <title>php中文網(wǎng)index</title> <style> /* 頁(yè)面初始化 */ /*css reset*/ body, ul, ol, dl, dd, p, h1, h2, h3, h4, h5, h6, form, fieldset, legend, img, video { margin: 0; padding: 0; } h1, h2, h3, h4, h5, h6 { font-weight: normal; } fieldset, img, input, button { border: none; padding: 0; margin: 0; outline-style: none; } ul, ol { list-style: none; } input { padding-top: 0; padding-bottom: 0; } select, input { vertical-align: middle; } select, input, textarea { outline: none; font-size: 14px; margin: 0; } i,s{ font-style: normal; } /*防止拖動(dòng)*/ textarea { resize: none; } /* 去掉圖片低測(cè)默認(rèn)的3像素空白縫隙*/ img { border: 0; vertical-align: middle; } table { border-collapse: collapse; } body { font-family: Helvetica Neue For Number, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif; line-height: 1.5; color: rgba(0, 0, 0, .65); font-size: 14px; } /*清除浮動(dòng)*/ .clearfix:before, .clearfix:after { content: ""; display: table; } .clearfix:after { clear: both; } .clearfix { *zoom: 1; /*IE/7/6*/ } a { color: #333; text-decoration: none; } a:hover { color: #139dff !important; } body { min-width: 320px; max-width: 768px; margin: 0 auto 50PX; background: #edeff0; overflow-y: initial; position: relative; /*不要出現(xiàn)水平滾動(dòng)條*/ overflow-x: hidden; /*設(shè)置點(diǎn)擊鏈接跳轉(zhuǎn)時(shí)出現(xiàn)高亮,設(shè)置為透明: ios / ipad*/ -webkit-tap-highlight-color: transparent; } /* 頁(yè)面開(kāi)始 */ /* 頭部導(dǎo)航欄 top-nav*/ .top { position: fixed; top: 0; width: 100%; height: 42px; background-color: #444444; min-width: 320px; max-width: 768px; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); } .top { display: flex; } .top img:first-of-type, .top img:last-of-type { width: 25px; height: 25px; margin-top: 8px; } .top img:first-of-type { border-radius: 50%; margin-left: 5px; } .top .logo { text-align: center; flex: 1; } .top .logo img { width: 94px; height: 45px; margin: 0; } /* 頭部導(dǎo)航欄 top-nav end*/ /*輪播圖 start */ .banner { display: flex; } .banner img { width: 100%; height: 160px; } /*輪播圖 end */ /* 導(dǎo)航區(qū) start*/ .nav { height: 170px; background-color: white; /* 避免撐大盒子 */ box-sizing: border-box; } .nav ul { padding: 6px; /* 彈性布局 */ display: flex; } .nav ul li { text-align: center; height: 75px; /* 平均分配剩余空間,每個(gè)項(xiàng)目大小一至 */ flex: 1; } .nav ul li img { width: 45px; height: 45px; } .nav ul li a { color: gray; } /* 導(dǎo)航區(qū) end */ /* 推薦課程區(qū) start */ h3 { color:gray; margin: 10px 10px; } .courses { /* height: 326px; */ color: gray; } .courses ul { display: flex; } .courses ul li { padding: 5px; } .courses ul img { width: 100%; height: 90px; } .courses div { background-color: white; height: 90px; padding: 10px; margin: 5px; /* flex布局 */ display: flex; justify-content: flex-start; } .courses div img { width: 100%; height: 90px; } .courses div a { color: gray; flex: 0.50; } .courses>div>p { box-sizing: border-box; flex: 0.50; /* text-align: center; */ display: flex; /* flex-flow: row wrap; */ flex-flow: column wrap; padding-left: 10px; } .courses div p>a { text-align: center; font-size: 1.2em; overflow: hidden; max-width: 95%; text-overflow: ellipsis; -o-text-overflow: ellipsis; white-space:nowrap; } .courses div p .span-t { font-size: 0.8rem; background-color: black; color: white; border-radius: 30%; padding: 0 2px; } .courses div p span:last-of-type { font-size: 0.7rem; } /* 推薦課程區(qū) end */ /* 最新更新 start */ .span-t2 { overflow: hidden; text-overflow: ellipsis; -o-text-overflow: ellipsis; white-space:nowrap; max-width: 166px; font-size: 11PX; } .update { justify-content: space-between; } .span-3 { display: flex; flex-flow: row nowrap; justify-content: space-between; } /* 最新更新 end */ /* 最新文章 start */ .New-article div { background-color: white; height: 65px; padding: 10px; margin: 5px; /* flex布局 */ display: flex; justify-content: flex-start; } .New-article div img { width: 100%; height: 65px; } .New-article div a { color: gray; flex: 0.40; font-weight: 700; } .New-article>div>p { box-sizing: border-box; flex: 0.60; /* text-align: center; */ display: flex; /* flex-flow: row wrap; */ flex-flow: column wrap; } .New-article div p>a { font-size: 1.2em; overflow: hidden; max-width: 195px; text-overflow: ellipsis; -o-text-overflow: ellipsis; white-space:nowrap; flex: 0.7; } .New-article div p .span-t { font-size: 0.8rem; background-color: black; color: white; border-radius: 30%; padding: 0 2px; } .New-article div p span:last-of-type { font-size: 0.7rem; } .btn-p { padding: 5px; } .btn-p button { width: 100%; padding: 10px 0; background-color: white; } /* 最新文章 edn*/ /* 最新博文 start*/ .Latest-blog a { background-color: white; display: flex; flex-flow: row nowrap; justify-content: space-between; padding: 10px 10px 20px; color: #888; margin: 0 5px 5px; } .Latest-blog a h2 { max-width: 220px; font-size: 14px; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* 最新博文 edn*/ /* 底部菜單 start */ .footer { position: fixed; bottom: 0; width: 100%; height: 42px; min-width: 320px; max-width: 768px; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); background-color: white; } .footer ul { display: flex; text-align: center; } .footer ul li img { width:20px; height: 20px; } .footer ul li a { color: gray; } .footer ul li { flex: 1; } /* 底部菜單 end */ </style> </head> <body> <!--布局原則: 寬寬自適應(yīng), 高度是固定--> <!-- 頭部導(dǎo)航欄 --> <div class="top"> <img src="static/images/user-pic.jpeg" alt=""> <div class="logo"> <img src="static/images/logo.png" alt=""> </div> <img src="static/images/user-nav.jpg" alt=""> </div> <!--banner輪播圖,這里用圖片暫時(shí)代替--> <div class="banner"> <img src="static/images/banner.jpg" alt=""> </div> <!-- 導(dǎo)航區(qū) --> <div class="nav"> <ul> <li><a href=""><img src="static/images/html.png" alt=""><br>HTML/CSS</a></li> <li><a href=""><img src="static/images/JavaScript.png" alt=""><br>JavaScript</a></li> <li><a href=""><img src="static/images/code.png" alt=""><br>服務(wù)端</a></li> <li><a href=""><img src="static/images/sql.png" alt=""><br>數(shù)據(jù)庫(kù)</a></li> </ul> <ul> <li><a href=""><img src="static/images/app.png" alt=""><br>移動(dòng)端</a></li> <li><a href=""><img src="static/images/manual.png" alt=""><br>手冊(cè)</a></li> <li><a href=""><img src="static/images/tool2.png" alt=""><br>工具</a></li> <li><a href=""><img src="static/images/live.png" alt=""><br>直播</a></li> </ul> </div> <!--課程區(qū)--> <h3>推薦課程</h3> <div class="courses"> <ul> <li> <a href=""><img src="static/images/tjkc1.jpg" alt=""></a> </li> <li> <a href=""><img src="static/images/tjkc2.jpg" alt=""></a> </li> </ul> <div> <a href=""><img src="static/images/tjkc3.jpg" alt=""></a> <p> <a href="">CI框架30分鐘極速入門</a> <!-- <br> --> <span><span class="span-t">初級(jí)</span><span>210066次播放</span></span> </p> </div> <div> <a href=""><img src="static/images/tjkc4.jpg" alt=""></a> <p> <a href="">2018前端入門_HTML5</a> <!-- <br> --> <span><span class="span-t">初級(jí)</span><span>210066次播放</span></span> </p> </div> </div> <!-- 最新更新 --> <h3>最新更新</h3> <div class="courses"> <div> <a href=""><img src="static/images/tjkc3.jpg" alt=""></a> <p class="update"> <a href="">CI框架30分鐘極速入門</a> <!-- <br> --> <span class="span-t2">傳說(shuō)中的那條又腥又咸又臭又硬的大咸魚(yú)勉強(qiáng)翻身都不行</span> <!-- <br> --> <span class="span-3"><span class="span-t">初級(jí)</span><span>210066次播放</span></span> </p> </div> <div> <a href=""><img src="static/images/tjkc4.jpg" alt=""></a> <p class="update"> <a href="">2018前端入門_HTML5</a> <!-- <br> --> <span class="span-t2">傳說(shuō)中的那條又腥又咸又臭又硬的大咸魚(yú)勉強(qiáng)翻身都不行</span> <!-- <br> --> <span class="span-3"><span class="span-t">初級(jí)</span><span>210066次播放</span></span> </p> </div> </div> <!-- 最新文章 --> <h3>最新文章</h3> <div class="New-article"> <div> <p class=""> <a href="">CI框架30分鐘極速入門</a> <span class=""><span>發(fā)布時(shí)間:</span><span>210066次播放</span></span> </p> <a href=""><img src="static/images/tjkc3.jpg" alt=""></a> </div> <div> <p class=""> <a href="">2018前端入門_HTML5</a> <span class=""><span>發(fā)布時(shí)間:</span><span>210066次播放</span></span> </p> <a href=""><img src="static/images/tjkc4.jpg" alt=""></a> </div> <p class="btn-p"><button type="button">更多類容</button></p> </div> <!-- 最新博文 --> <h3>最新博文</h3> <div class="Latest-blog"> <a href=""> <h2>mysql查詢時(shí)間戳和日期的轉(zhuǎn)換</h2> <span>2019-09-07</span> </a> <a href=""> <h2>mysql查詢時(shí)間戳和日期的轉(zhuǎn)換</h2> <span>2019-09-07</span> </a> <a href=""> <h2>mysql查詢時(shí)間戳和日期的轉(zhuǎn)換</h2> <span>2019-09-07</span> </a> <p class="btn-p"><button type="button">更多類容</button></p> </div> <!-- 最新問(wèn)答 --> <h3>最新問(wèn)答</h3> <div class="Latest-blog"> <a href=""> <h2>mysql查詢時(shí)間戳和日期的轉(zhuǎn)換</h2> <span>2019-09-07</span> </a> <a href=""> <h2>mysql查詢時(shí)間戳和日期的轉(zhuǎn)換</h2> <span>2019-09-07</span> </a> <a href=""> <h2>mysql查詢時(shí)間戳和日期的轉(zhuǎn)換</h2> <span>2019-09-07</span> </a> <p class="btn-p"><button type="button">更多類容</button></p> </div> <!--底部--> <div class="footer"> <ul> <li><a href=""><img src="static/font-icon/zhuye.png" alt=""> <br><span>主頁(yè)</span></a></li> <li><a href=""><img src="static/font-icon/video.png" alt=""> <br><span>視頻</span></a></li> <li><a href=""><img src="static/font-icon/luntan.png" alt=""><br><span>社區(qū)</span></a></li> <li><a href=""><img src="static/font-icon/geren.png" alt=""> <br><span>我的</span></a></li> </ul> </div> </body> </html>
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)