仿m.php.cn自适应移动端页面首页
效果图:
实例
<!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中文网index</title> <style> /* 页面初始化 */ /*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; } /*防止拖动*/ textarea { resize: none; } /* 去掉图片低测默认的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; } /*清除浮动*/ .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; /*不要出现水平滚动条*/ overflow-x: hidden; /*设置点击链接跳转时出现高亮,设置为透明: ios / ipad*/ -webkit-tap-highlight-color: transparent; } /* 页面开始 */ /* 头部导航栏 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; } /* 头部导航栏 top-nav end*/ /*轮播图 start */ .banner { display: flex; } .banner img { width: 100%; height: 160px; } /*轮播图 end */ /* 导航区 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; /* 平均分配剩余空间,每个项目大小一至 */ flex: 1; } .nav ul li img { width: 45px; height: 45px; } .nav ul li a { color: gray; } /* 导航区 end */ /* 推荐课程区 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; } /* 推荐课程区 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> <!--布局原则: 宽宽自适应, 高度是固定--> <!-- 头部导航栏 --> <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轮播图,这里用图片暂时代替--> <div class="banner"> <img src="static/images/banner.jpg" alt=""> </div> <!-- 导航区 --> <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>服务端</a></li> <li><a href=""><img src="static/images/sql.png" alt=""><br>数据库</a></li> </ul> <ul> <li><a href=""><img src="static/images/app.png" alt=""><br>移动端</a></li> <li><a href=""><img src="static/images/manual.png" alt=""><br>手册</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> <!--课程区--> <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">初级</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">初级</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">传说中的那条又腥又咸又臭又硬的大咸鱼勉强翻身都不行</span> <!-- <br> --> <span class="span-3"><span class="span-t">初级</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">传说中的那条又腥又咸又臭又硬的大咸鱼勉强翻身都不行</span> <!-- <br> --> <span class="span-3"><span class="span-t">初级</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>发布时间:</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>发布时间:</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查询时间戳和日期的转换</h2> <span>2019-09-07</span> </a> <a href=""> <h2>mysql查询时间戳和日期的转换</h2> <span>2019-09-07</span> </a> <a href=""> <h2>mysql查询时间戳和日期的转换</h2> <span>2019-09-07</span> </a> <p class="btn-p"><button type="button">更多类容</button></p> </div> <!-- 最新问答 --> <h3>最新问答</h3> <div class="Latest-blog"> <a href=""> <h2>mysql查询时间戳和日期的转换</h2> <span>2019-09-07</span> </a> <a href=""> <h2>mysql查询时间戳和日期的转换</h2> <span>2019-09-07</span> </a> <a href=""> <h2>mysql查询时间戳和日期的转换</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>主页</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>社区</span></a></li> <li><a href=""><img src="static/font-icon/geren.png" alt=""> <br><span>我的</span></a></li> </ul> </div> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例