Blogger Information
Blog 38
fans 1
comment 0
visits 28741
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Flex实战之实现PHP中文网移动端首页 - 九期线上班
fkkf467
Original
679 people have browsed it

1. PHP中文网移动端首页

html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>PHP中文网手机版首页</title>
  6. <link rel="stylesheet" href="static/css/init.css">
  7. <link rel="stylesheet" href="static/css/style.css">
  8. </head>
  9. <body>
  10. <!--布局原则 宽度自适应,高度固定-->
  11. <!--顶部设置为固定定位-->
  12. <header>
  13. <img src="static/images/user-pic.jpeg" alt="">
  14. <img src="static/images/logo.png" alt="">
  15. <img src="static/images/user-nav.jpg" alt="">
  16. </header>
  17. <!--轮播图用图片代替-->
  18. <div class="banner">
  19. <img src="static/images/banner.jpg" alt="">
  20. </div>
  21. <!--导航区-->
  22. <nav>
  23. <ul>
  24. <li>
  25. <a href="">
  26. <img src="static/images/html.png" alt="">
  27. <span>HTML/CSS</span>
  28. </a>
  29. </li>
  30. <li>
  31. <a href="">
  32. <img src="static/images/JavaScript.png" alt="">
  33. <span>JavaScript</span>
  34. </a>
  35. </li>
  36. <li>
  37. <a href="">
  38. <img src="static/images/code.png" alt="">
  39. <span>服务端</span>
  40. </a>
  41. </li>
  42. <li>
  43. <a href="">
  44. <img src="static/images/sql.png" alt="">
  45. <span>数据库</span>
  46. </a>
  47. </li>
  48. </ul>
  49. <ul>
  50. <li>
  51. <a href=""><img src="static/images/app.png" alt="">
  52. <span>移动端</span>
  53. </a>
  54. </li>
  55. <li>
  56. <a href="">
  57. <img src="static/images/manual.png" alt="">
  58. <span>手册</span>
  59. </a>
  60. </li>
  61. <li>
  62. <a href=""><img src="static/images/tool2.png" alt="">
  63. <span>工具</span>
  64. </a>
  65. </li>
  66. <li>
  67. <a href="">
  68. <img src="static/images/live.png" alt="">
  69. <span>直播</span>
  70. </a>
  71. </li>
  72. </ul>
  73. </nav>
  74. <!--课程区-->
  75. <main>
  76. <!-- 推荐课程区-->
  77. <article class="recommend">
  78. <h3>推荐课程</h3>
  79. <section>
  80. <a href=""><img src="static/images/tjkc1.jpg" alt=""></a>
  81. <a href=""><img src="static/images/tjkc2.jpg" alt=""></a>
  82. </section>
  83. <section>
  84. <div>
  85. <a href=""><img src="static/images/tjkc3.jpg" alt=""></a>
  86. <span>
  87. <a href="">CI框架30分钟极速入门</a>
  88. <span><i>中级</i>49738次播放</span>
  89. </span>
  90. </div>
  91. <div>
  92. <a href=""><img src="static/images/tjkc4.jpg" alt=""></a>
  93. <span>
  94. <a href="">2018前端入门基础</a>
  95. <span><i>初级</i>209952次播放</span>
  96. </span>
  97. </div>
  98. </section>
  99. </article>
  100. <!-- 最新更新-->
  101. <article>
  102. <h3>最新更新</h3>
  103. <section class="update">
  104. <div>
  105. <a href=""><img src="static/images/zxgx1.jpg" alt=""></a>
  106. <div>
  107. <a href="">2019python自学视频</a>
  108. <p>本课程适合想从零开始学习 python 编程语言的开发人员。由浅入深的带你进入p...</p>
  109. <span><i>初级</i>2280次播放</span>
  110. </div>
  111. </div>
  112. <div>
  113. <a href=""><img src="static/images/zxgx2.png" alt=""></a>
  114. <div>
  115. <a href="">PHP开发免费公益直播课</a>
  116. <p>主讲:PHP中文网-朱老师(Peter Zhu)时间:2019.10.17 晚 20:00-22:00 主题:...</p>
  117. <span><i>初级</i>1766次播放</span>
  118. </div>
  119. </div>
  120. <div>
  121. <a href=""><img src="static/images/zxgx3.jpg" alt=""></a>
  122. <div>
  123. <a href="">从零开始到WEB响应式布局</a>
  124. <p>重点介绍了HTML、CSS、web布局前端核心技术,通过视频讲解,了解可以利...</p>
  125. <span><i>初级</i>3255次播放</span>
  126. </div>
  127. </div>
  128. <div>
  129. <a href=""><img src="static/images/zxgx4.png" alt=""></a>
  130. <div>
  131. <a href="">PHP文件基础操作</a>
  132. <p>好多同学在PHP基础的时候对PHP文件的操作了解的不够多,本节课就带着大家...</p>
  133. <span><i>中级</i>1719次播放</span>
  134. </div>
  135. </div>
  136. <div>
  137. <a href=""><img src="static/images/zxgx5.jpg" alt=""></a>
  138. <div>
  139. <a href="">memcache基础课程</a>
  140. <p>本课程带你从零认识memcache,让你在一小时左右轻松掌握memcache在wind...</p>
  141. <span><i>初级</i>829次播放</span>
  142. </div>
  143. </div>
  144. <div>
  145. <a href=""><img src="static/images/zxgx6.png" alt=""></a>
  146. <div>
  147. <a href="">微信小程序--企业微网站</a>
  148. <p>1,介绍小程序、开发者工具 2,介绍小程序文档 3,微官网项目 4,首页、产品...</p>
  149. <span><i>初级</i>3747次播放</span>
  150. </div>
  151. </div>
  152. </section>
  153. </article>
  154. <!-- 最新文章-->
  155. <article>
  156. <h3>最新文章</h3>
  157. <section class="essay">
  158. <a href="">
  159. <span>
  160. <h4>PHP如何去除数组中的空值?(图文+视频)</h4>
  161. <span>发布时间:2018-10-09</span>
  162. </span>
  163. <img src="static/images/zxwz1.png" alt="">
  164. </a>
  165. <a href="">
  166. <span>
  167. <h4>PHP冒泡排序算法是怎么实现的?(图文+视频)</h4>
  168. <span>发布时间:2018-10-08</span>
  169. </span>
  170. <img src="static/images/zxwz2.png" alt="">
  171. </a>
  172. <a href="">
  173. <span>
  174. <h4>ThinkPHP5.1框架怎么通过Composer下载安装?(图文+视频)</h4>
  175. <span>发布时间:2018-09-20</span>
  176. </span>
  177. <img src="static/images/zxwz3.png" alt="">
  178. </a>
  179. <a href="">
  180. <span>
  181. <h4>PHP怎么验证邮箱格式是否正确?(图文+视频)</h4>
  182. <span>发布时间:2018-09-26</span>
  183. </span>
  184. <img src="static/images/zxwz4.png" alt="">
  185. </a>
  186. <a href="">
  187. <span>
  188. <h4>PHPStorm怎么配置xdebug工具并使用?(图文+视频)</h4>
  189. <span>发布时间:2018-09-14</span>
  190. </span>
  191. <img src="static/images/zxwz5.png" alt="">
  192. </a>
  193. <a href="">
  194. <span>更多内容</span>
  195. </a>
  196. </section>
  197. </article>
  198. <!-- 最新博文-->
  199. <article>
  200. <h3>最新博文</h3>
  201. <section class="blog">
  202. <a href="">
  203. <h2>移动端、手机端、去掉横向滚动条 亲测生效!!!</h2>
  204. <span>2019-11-08</span>
  205. </a>
  206. <a href="">
  207. <h2>PHP学习第一天:软件安装篇</h2>
  208. <span>2019-11-08</span>
  209. </a>
  210. <a href="">
  211. <h2>Linux系统CentOS报错:could not resolve host:mirrorlist.centos.org问题</h2>
  212. <span>2019-11-08</span>
  213. </a>
  214. <a href="">
  215. <h2>thinkphp5.0.24前置操作的大小写问题</h2>
  216. <span>2019-11-07</span>
  217. </a>
  218. <a href="">
  219. <h2>laravel-创建“控制器”和“模型”,使用模型方法获取数据库内容并输出--2019...</h2>
  220. <span>2019-11-04</span>
  221. </a>
  222. <a href="">
  223. <span>更多内容</span>
  224. </a>
  225. </section>
  226. </article>
  227. <!-- 最新问答-->
  228. <article>
  229. <h3>最新问答</h3>
  230. <section class="blog">
  231. <a href="">
  232. <h2>在金沙网站玩AG视讯赢了不给有什么解决方法?</h2>
  233. <span>2019-11-09</span>
  234. </a>
  235. <a href="">
  236. <h2>在威尼斯网站玩AG视讯赢了不给怎么办?</h2>
  237. <span>2019-11-09</span>
  238. </a>
  239. <a href="">
  240. <h2>初来乍到,有什么不懂的地方还请大家多多指教。</h2>
  241. <span>2019-11-09</span>
  242. </a>
  243. <a href="">
  244. <h2>出现这个怎么解决呀</h2>
  245. <span>2019-11-09</span>
  246. </a>
  247. <a href="">
  248. <h2>登录密码 什么情况???</h2>
  249. <span>2019-11-09</span>
  250. </a>
  251. <a href="">
  252. <span>更多内容</span>
  253. </a>
  254. </section>
  255. </article>
  256. </main>
  257. <!--实现底部,底部与头部类似,也是固定定位实现-->
  258. <footer>
  259. <a href=""><img src="static/font-icon/zhuye.png" alt="">
  260. <span>主页</span>
  261. </a>
  262. <a href="">
  263. <img src="static/font-icon/video.png" alt="">
  264. <span>视频</span>
  265. </a>
  266. <a href="">
  267. <img src="static/font-icon/luntan.png" alt="">
  268. <span>社区</span>
  269. </a>
  270. <a href="">
  271. <img src="static/font-icon/geren.png" alt="">
  272. <span>我的</span>
  273. </a>
  274. </footer>
  275. </body>
  276. </html>

css代码 init.css

  1. body, footer {
  2. min-width: 320px;
  3. max-width: 768px;
  4. margin: 0 auto;
  5. background: #edeff0;
  6. overflow-y: initial;
  7. position: relative;
  8. color: gray;
  9. /*不要出现水平滚动条*/
  10. overflow-x: hidden;
  11. /*设置点击链接跳转时出现高亮,设置为透明:ios/ipad*/
  12. -webkit-tap-highlight-color: transparent;
  13. }
  14. /*设置所有图片全部自适应父容器,响应式显示*/
  15. img {
  16. width: 100%;
  17. }
  18. ul, li {
  19. margin: 0;
  20. padding: 0;
  21. }
  22. li {
  23. list-style: none;
  24. }
  25. a {
  26. text-decoration: none;
  27. color: gray;
  28. }

css代码 style.css

  1. /*顶部设置*/
  2. header {
  3. /*设置为固定定位*/
  4. position: fixed;
  5. top: 0;
  6. /*固定定位元素必须设置宽度和高度*/
  7. width: 100%;
  8. height: 42px;
  9. background: #444444;
  10. color: white;
  11. /*设置最小尺寸*/
  12. min-width: 320px;
  13. /*最大尺寸*/
  14. max-width: 768px;
  15. display: flex;
  16. justify-content: space-between;
  17. align-items: center;
  18. }
  19. /*第一张、最后一张图片设置通用样式*/
  20. header > img:first-of-type,
  21. header > img:last-of-type {
  22. width: 26px;
  23. height: 26px;
  24. margin: 5px;
  25. }
  26. /*用户头像设置为圆形*/
  27. header > img:first-of-type {
  28. border-radius: 50%;
  29. }
  30. /*设置中间logo样式*/
  31. header > img {
  32. width: 94px;
  33. }
  34. /*轮播图设置*/
  35. .banner {
  36. display: flex;
  37. height: 200px;
  38. }
  39. /*导航区设置*/
  40. nav {
  41. /*设置背景颜色为白色*/
  42. background-color: white;
  43. /*转为flex容器*/
  44. display: flex;
  45. /*主轴为垂直方向,且不换行*/
  46. flex-flow: column nowrap;
  47. }
  48. /*设置图片大小*/
  49. nav img {
  50. /*设置图片宽度*/
  51. width: 45px;
  52. /*设置图片高度*/
  53. height: 49px;
  54. }
  55. /*每一行导航都应该是一个弹性容器以方便布局*/
  56. nav > ul {
  57. /*转为flex容器*/
  58. display: flex;
  59. /*每个菜单项水平且不换行(默认值)*/
  60. flex-flow: row nowrap;
  61. }
  62. /*每一菜单项均分全部空间*/
  63. nav ul li {
  64. flex: 1;
  65. }
  66. /*图片与文本应该做为一个组件,统一设置*/
  67. nav ul li a {
  68. /*转为flex容器*/
  69. display: flex;
  70. /*图片, 链接文本垂直排列*/
  71. flex-flow: column nowrap;
  72. /*交叉轴上居中显示*/
  73. align-items: center;
  74. /*外边距可以使菜单项之间不太拥挤*/
  75. margin: 10px;
  76. }
  77. /*使菜单项文本与上面图标有一个间隙*/
  78. nav ul li a span {
  79. margin-top: 5px;
  80. }
  81. /*主体内容区*/
  82. /*推荐课程区*/
  83. main {
  84. width: 748px;
  85. margin: 20px auto 50px;
  86. display: flex;
  87. flex-flow: column nowrap;
  88. color: #888888;
  89. }
  90. .recommend > section:first-of-type {
  91. display: flex;
  92. justify-content: space-between;
  93. }
  94. .recommend > section:first-of-type > a > img {
  95. width: 366px;
  96. height: 90px;
  97. }
  98. .recommend > section:last-of-type {
  99. display: flex;
  100. flex-flow: column nowrap;
  101. margin-top: 20px;
  102. }
  103. .recommend > section:last-of-type > div,
  104. .update > div {
  105. box-sizing: border-box;
  106. height: 98px;
  107. margin: 0 0 20px;
  108. padding: 9px 0 9px 10px;
  109. background: #ffffff;
  110. display: flex;
  111. }
  112. .recommend > section:last-of-type > div > a > img,
  113. .update > div > a > img {
  114. width: 295.2px;
  115. height: 80px;
  116. }
  117. .recommend > section:last-of-type > div > span {
  118. display: flex;
  119. flex-flow: column nowrap;
  120. margin-left: 10px;
  121. }
  122. .recommend > section:last-of-type > div > span > a {
  123. font-size: 16.5px;
  124. color: #888888;
  125. }
  126. .recommend > section:last-of-type > div > span > span {
  127. margin: 11px 0 0;
  128. font-size: 11px;
  129. }
  130. .recommend > section:last-of-type > div > span > span > i,
  131. .update > div > div > span > i {
  132. font-style: normal;
  133. background-color: #595757;
  134. color: white;
  135. padding: 3px;
  136. font-size: 10px;
  137. border-radius: 8px;
  138. margin-right: 2px;
  139. }
  140. .update > div > div {
  141. box-sizing: border-box;
  142. display: flex;
  143. flex-flow: column nowrap;
  144. margin-left: 10px;
  145. }
  146. .update > div > div > a {
  147. color: #888888;
  148. font-size: 16.5px;
  149. }
  150. .update > div > div > p {
  151. font-size: 11px;
  152. }
  153. .update > div > div > span {
  154. font-size: 11px;
  155. }
  156. .update > div > div > span {
  157. display: flex;
  158. justify-content: space-between;
  159. }
  160. .essay a {
  161. box-sizing: border-box;
  162. height: 84px;
  163. margin: 0 0 10px;
  164. padding: 10px 10px 8px;
  165. background: #ffffff;
  166. display: flex;
  167. justify-content: space-between;
  168. }
  169. .essay a > img {
  170. width: 218.4px;
  171. height: 65px;
  172. }
  173. .essay > a > span > h4 {
  174. font-size: 14px;
  175. color: #888888;
  176. margin: 0 0 10px;
  177. }
  178. .essay > a > span > span {
  179. font-size: 12px;
  180. color: #888888;
  181. }
  182. .essay > a:last-of-type,
  183. .blog > a:last-of-type {
  184. height: 29.6px;
  185. box-sizing: border-box;
  186. display: flex;
  187. justify-content: center;
  188. align-items: center;
  189. }
  190. .essay > a:last-of-type > span,
  191. .blog > a:last-of-type > span {
  192. font-size: 14px;
  193. color: #888888;
  194. }
  195. .blog > a {
  196. box-sizing: border-box;
  197. height: 48.2px;
  198. margin: 0 0 10px;
  199. padding: 10px 10px 8px;
  200. background: #ffffff;
  201. display: flex;
  202. justify-content: space-between;
  203. }
  204. .blog > a > h2 {
  205. font-size: 14px;
  206. color: #888888;
  207. margin: 0 0 10px;
  208. }
  209. .blog > a > span {
  210. font-size: 12px;
  211. color: #888888;
  212. }
  213. footer {
  214. position: fixed;
  215. bottom: 0;
  216. width: 100%;
  217. height: 50px;
  218. box-sizing: border-box;
  219. background-color: #eeeeee;
  220. display: flex;
  221. align-items: center;
  222. border-top: 1px solid #CCCCCC;
  223. }
  224. footer > a {
  225. flex: 1;
  226. box-sizing: border-box;
  227. display: flex;
  228. flex-flow: column nowrap;
  229. align-items: center;
  230. margin-top: 2px;
  231. }
  232. footer > a > img {
  233. width: 16px;
  234. height: 16.8px;
  235. }

2. 手抄代码


3. 总结

通过对PHP中文网移动端首页的实现,更加了解了flex,也了解了设计移动端页面的基本思路。

Correction status:qualified

Teacher's comments:flex用于轴线一维布局, 理论上讲, 任何页面都可以写, 不论是PC还是移动
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments