Blogger Information
Blog 62
fans 7
comment 2
visits 58280
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
使用flex布局实战模仿php中文网移动端
我是郭富城
Original
694 people have browsed it

演示站:https://php520.vip/final/php.cn.html
请切换至手机模式,或者直接使用手机浏览效果更佳

确认文档结构

  • 第一步是最核心的,需要清楚自己的html文档的具体结构

    实际上明确文档结构就是在脑海中浮现出即将要实现的html页面,知道他的结构和内容

通用的基本样式设置

  • css通用的基本样式

以下是完整的代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <link rel="stylesheet" href="css/icon.css" />
  7. <title>使用flex布局实战模仿php中文网移动端</title>
  8. <style>
  9. * {
  10. padding: 0;
  11. margin: 0;
  12. }
  13. a {
  14. text-decoration: none;
  15. color: #666;
  16. }
  17. html {
  18. width: 100vw;
  19. height: 100vh;
  20. font-size: 14px;
  21. }
  22. body {
  23. min-width: 360px;
  24. background-color: #edeff0;
  25. display: flex;
  26. flex-flow: column nowrap;
  27. }
  28. header {
  29. height: 50px;
  30. background-color: #2d353c;
  31. display: flex;
  32. flex-flow: row nowrap;
  33. align-items: center;
  34. justify-content: space-between;
  35. padding: 0 15px;
  36. position: fixed;
  37. width: 95vw;
  38. }
  39. header > a:first-of-type > span {
  40. font-size: 1.8rem;
  41. }
  42. header > a:last-of-type > span {
  43. font-size: 1.8rem;
  44. color: #fff;
  45. }
  46. header img {
  47. width: 80px;
  48. }
  49. .slider {
  50. height: 160px;
  51. margin-top: 50px;
  52. }
  53. .slider > img {
  54. width: 100%;
  55. }
  56. nav {
  57. height: 180px;
  58. display: flex;
  59. flex-flow: row wrap;
  60. }
  61. nav > div {
  62. width: 25vw;
  63. display: flex;
  64. flex-flow: column nowrap;
  65. align-items: center;
  66. }
  67. nav > div > a:first-of-type > img {
  68. width: 50%;
  69. }
  70. nav > div > a:first-of-type {
  71. text-align: center;
  72. }
  73. h3 {
  74. color: #888a8c;
  75. padding-left: 5px;
  76. }
  77. .tuijian-course {
  78. height: 350px;
  79. display: flex;
  80. flex-flow: column nowrap;
  81. margin-top: 10px;
  82. }
  83. .tuijian-course > div:first-of-type {
  84. display: flex;
  85. flex-flow: row nowrap;
  86. justify-content: space-evenly;
  87. }
  88. .tuijian-course > div:first-of-type > img {
  89. width: 45vw;
  90. }
  91. .tuijian-course > div:nth-of-type(2) {
  92. display: flex;
  93. flex-flow: row nowrap;
  94. background-color: #fff;
  95. margin: 12px;
  96. box-sizing: border-box;
  97. }
  98. .tuijian-course > div:nth-of-type(2) > img {
  99. width: 40vw;
  100. padding: 10px;
  101. }
  102. .tuijian-course > div:nth-of-type(2) > div {
  103. display: flex;
  104. flex-flow: column nowrap;
  105. justify-content: space-evenly;
  106. }
  107. .tuijian-course > div:nth-of-type(2) > div > a:first-of-type {
  108. font-size: 1.2rem;
  109. }
  110. .tuijian-course > div:nth-of-type(2) > div > a:last-of-type {
  111. font-size: 0.8rem;
  112. }
  113. .tuijian-course > div:nth-of-type(2) > div > a:last-of-type > span {
  114. background-color: #595757;
  115. color: #fff;
  116. border-radius: 6px;
  117. }
  118. .tuijian-course > div:last-of-type {
  119. display: flex;
  120. flex-flow: row nowrap;
  121. background-color: #fff;
  122. margin: 12px;
  123. box-sizing: border-box;
  124. }
  125. .tuijian-course > div:last-of-type > img {
  126. width: 40vw;
  127. padding: 10px;
  128. }
  129. .tuijian-course > div:last-of-type > div {
  130. display: flex;
  131. flex-flow: column nowrap;
  132. justify-content: space-evenly;
  133. }
  134. .tuijian-course > div:last-of-type > div > a:first-of-type {
  135. font-size: 1.2rem;
  136. }
  137. .tuijian-course > div:last-of-type > div > a:last-of-type {
  138. font-size: 0.8rem;
  139. }
  140. .tuijian-course > div:last-of-type > div > a:last-of-type > span {
  141. background-color: #595757;
  142. color: #fff;
  143. border-radius: 6px;
  144. }
  145. .zuixin {
  146. height: 800px;
  147. display: flex;
  148. flex-flow: column nowrap;
  149. justify-content: space-evenly;
  150. }
  151. .zuixin > .tuwen {
  152. display: flex;
  153. flex-flow: row nowrap;
  154. background-color: #fff;
  155. margin: 12px;
  156. }
  157. .zuixin > .tuwen > a > img {
  158. width: 40vw;
  159. padding: 10px;
  160. }
  161. .miaoshu {
  162. display: flex;
  163. flex-flow: column nowrap;
  164. justify-content: space-evenly;
  165. }
  166. .miaoshu > a:first-of-type {
  167. font-size: 1.2rem;
  168. }
  169. .miaoshu > a:last-of-type {
  170. font-size: 0.8rem;
  171. }
  172. .miaoshu > div {
  173. display: flex;
  174. flex-flow: row nowrap;
  175. justify-content: space-between;
  176. }
  177. .miaoshu > div > span:first-of-type {
  178. background-color: #595757;
  179. border-radius: 5px;
  180. font-size: 0.8rem;
  181. color: #fff;
  182. }
  183. .miaoshu > div > span:last-of-type {
  184. font-size: 0.8rem;
  185. color: #88a5c4;
  186. }
  187. .zuixin-article {
  188. display: flex;
  189. flex-flow: column nowrap;
  190. justify-content: space-evenly;
  191. }
  192. .zuowen {
  193. display: flex;
  194. background-color: #fff;
  195. margin: 12px;
  196. justify-content: space-between;
  197. }
  198. .zuowen > a > img {
  199. width: 35vw;
  200. height: 65px;
  201. padding: 10px;
  202. }
  203. .zuowen > div {
  204. display: flex;
  205. flex-flow: column nowrap;
  206. justify-content: space-evenly;
  207. padding: 10px;
  208. }
  209. .zuowen > div > a:first-of-type {
  210. font-weight: bold;
  211. font-size: 0.9rem;
  212. }
  213. .zuowen > div > a:last-of-type {
  214. font-size: 0.8rem;
  215. }
  216. .gengduo {
  217. background-color: #fff;
  218. height: 30px;
  219. margin: 12px;
  220. display: flex;
  221. justify-content: center;
  222. align-items: center;
  223. }
  224. .zuixin-bowen {
  225. display: flex;
  226. flex-flow: column nowrap;
  227. justify-content: space-between;
  228. }
  229. .bowen {
  230. display: flex;
  231. flex-flow: row nowrap;
  232. background-color: #fff;
  233. height: 40px;
  234. margin: 12px;
  235. align-items: center;
  236. justify-content: space-around;
  237. }
  238. .bowen > a:first-of-type {
  239. font-weight: bold;
  240. }
  241. footer {
  242. height: 50px;
  243. background-color: #eeeeee;
  244. display: flex;
  245. justify-content: space-around;
  246. position: fixed;
  247. width: 100vw;
  248. bottom: 0;
  249. align-items: center;
  250. }
  251. footer > div {
  252. display: flex;
  253. flex-flow: column nowrap;
  254. align-items: center;
  255. }
  256. footer > div > a:first-of-type > span {
  257. font-size: 1.4rem;
  258. }
  259. </style>
  260. </head>
  261. <body>
  262. <!-- 页眉 -->
  263. <header>
  264. <a href=""><span class="iconfont"></span></a>
  265. <a href=""><img src="img/logo.png" alt="" /></a>
  266. <a href=""><span class="iconfont"></span></a>
  267. </header>
  268. <!-- 轮播图 -->
  269. <div class="slider">
  270. <img src="img/2.jpg" alt="" />
  271. </div>
  272. <!-- 导航 -->
  273. <nav>
  274. <div>
  275. <a href=""><img src="img/html.png" alt="" /></a>
  276. <a href="">HTML/CSS</a>
  277. </div>
  278. <div>
  279. <a href=""><img src="img/JavaScript.png" alt="" /></a>
  280. <a href="">JacaScript</a>
  281. </div>
  282. <div>
  283. <a href=""><img src="img/code.png" alt="" /></a>
  284. <a href="">服务端</a>
  285. </div>
  286. <div>
  287. <a href=""><img src="img/sql.png" alt="" /></a>
  288. <a href="">数据库</a>
  289. </div>
  290. <div>
  291. <a href=""><img src="img/app.png" alt="" /></a>
  292. <a href="">移动端</a>
  293. </div>
  294. <div>
  295. <a href=""><img src="img/manual.png" alt="" /></a>
  296. <a href="">手册</a>
  297. </div>
  298. <div>
  299. <a href=""><img src="img/tool2.png" alt="" /></a>
  300. <a href="">工具</a>
  301. </div>
  302. <div>
  303. <a href=""><img src="img/live.png" alt="" /></a>
  304. <a href="">直播</a>
  305. </div>
  306. </nav>
  307. <!-- 推荐课程 -->
  308. <h3>推荐课程</h3>
  309. <div class="tuijian-course">
  310. <div>
  311. <img src="img/tianlong.jpg" alt="" />
  312. <img src="img/tianlong2.jpg" alt="" />
  313. </div>
  314. <div>
  315. <img src="img/30.jpg" alt="" />
  316. <div>
  317. <a href="">CI框架30分钟极速入门</a>
  318. <a href=""><span>中级</span>61401次播放</a>
  319. </div>
  320. </div>
  321. <div>
  322. <img src="img/30.jpg" alt="" />
  323. <div>
  324. <a href="">CI框架30分钟极速入门</a>
  325. <a href=""><span>中级</span>61401次播放</a>
  326. </div>
  327. </div>
  328. </div>
  329. <!-- 最新更新 -->
  330. <h3>最新更新</h3>
  331. <div class="zuixin">
  332. <div class="tuwen">
  333. <a href=""><img src="img/excel.png" alt="" /></a>
  334. <div class="miaoshu">
  335. <a href="">php快速操控EXcel之P...</a>
  336. <a>老的phpexcel已经停止更新了!目...</a>
  337. <div>
  338. <span>中级</span>
  339. <span>49862次播放</span>
  340. </div>
  341. </div>
  342. </div>
  343. <div class="tuwen">
  344. <a href=""><img src="img/excel.png" alt="" /></a>
  345. <div class="miaoshu">
  346. <a href="">php快速操控EXcel之P...</a>
  347. <a>老的phpexcel已经停止更新了!目...</a>
  348. <div>
  349. <span>中级</span>
  350. <span>49862次播放</span>
  351. </div>
  352. </div>
  353. </div>
  354. <div class="tuwen">
  355. <a href=""><img src="img/excel.png" alt="" /></a>
  356. <div class="miaoshu">
  357. <a href="">php快速操控EXcel之P...</a>
  358. <a>老的phpexcel已经停止更新了!目...</a>
  359. <div>
  360. <span>中级</span>
  361. <span>49862次播放</span>
  362. </div>
  363. </div>
  364. </div>
  365. <div class="tuwen">
  366. <a href=""><img src="img/excel.png" alt="" /></a>
  367. <div class="miaoshu">
  368. <a href="">php快速操控EXcel之P...</a>
  369. <a>老的phpexcel已经停止更新了!目...</a>
  370. <div>
  371. <span>中级</span>
  372. <span>49862次播放</span>
  373. </div>
  374. </div>
  375. </div>
  376. <div class="tuwen">
  377. <a href=""><img src="img/excel.png" alt="" /></a>
  378. <div class="miaoshu">
  379. <a href="">php快速操控EXcel之P...</a>
  380. <a>老的phpexcel已经停止更新了!目...</a>
  381. <div>
  382. <span>中级</span>
  383. <span>49862次播放</span>
  384. </div>
  385. </div>
  386. </div>
  387. <div class="tuwen">
  388. <a href=""><img src="img/excel.png" alt="" /></a>
  389. <div class="miaoshu">
  390. <a href="">php快速操控EXcel之P...</a>
  391. <a>老的phpexcel已经停止更新了!目...</a>
  392. <div>
  393. <span>中级</span>
  394. <span>49862次播放</span>
  395. </div>
  396. </div>
  397. </div>
  398. </div>
  399. <!-- 最新文章 -->
  400. <h3>最新文章</h3>
  401. <div class="zuixin-article">
  402. <div class="zuowen">
  403. <div>
  404. <a href="">如何在linux环境下安装docker</a>
  405. <a href="">发布时间:2020-04-14</a>
  406. </div>
  407. <a href=""><img src="img/qie.jpg" alt="" /></a>
  408. </div>
  409. <div class="zuowen">
  410. <div>
  411. <a href="">如何在linux环境下安装docker</a>
  412. <a href="">发布时间:2020-04-14</a>
  413. </div>
  414. <a href=""><img src="img/qie.jpg" alt="" /></a>
  415. </div>
  416. <div class="zuowen">
  417. <div>
  418. <a href="">如何在linux环境下安装docker</a>
  419. <a href="">发布时间:2020-04-14</a>
  420. </div>
  421. <a href=""><img src="img/qie.jpg" alt="" /></a>
  422. </div>
  423. <div class="zuowen">
  424. <div>
  425. <a href="">如何在linux环境下安装docker</a>
  426. <a href="">发布时间:2020-04-14</a>
  427. </div>
  428. <a href=""><img src="img/qie.jpg" alt="" /></a>
  429. </div>
  430. <div class="zuowen">
  431. <div>
  432. <a href="">如何在linux环境下安装docker</a>
  433. <a href="">发布时间:2020-04-14</a>
  434. </div>
  435. <a href=""><img src="img/qie.jpg" alt="" /></a>
  436. </div>
  437. </div>
  438. <div class="gengduo">
  439. <a href="">更多内容</a>
  440. </div>
  441. <!-- 最新博文 -->
  442. <h3>最新博文</h3>
  443. <div class="zuixin-bowen">
  444. <div class="bowen">
  445. <a href="">phpstrom安装PHPUnit-9单元测试</a>
  446. <a href="">2020-04-14</a>
  447. </div>
  448. <div class="bowen">
  449. <a href="">phpstrom安装PHPUnit-9单元测试</a>
  450. <a href="">2020-04-14</a>
  451. </div>
  452. <div class="bowen">
  453. <a href="">phpstrom安装PHPUnit-9单元测试</a>
  454. <a href="">2020-04-14</a>
  455. </div>
  456. <div class="bowen">
  457. <a href="">phpstrom安装PHPUnit-9单元测试</a>
  458. <a href="">2020-04-14</a>
  459. </div>
  460. <div class="bowen">
  461. <a href="">phpstrom安装PHPUnit-9单元测试</a>
  462. <a href="">2020-04-14</a>
  463. </div>
  464. </div>
  465. <div class="gengduo">
  466. <a href="">更多内容</a>
  467. </div>
  468. <!-- 最新问答 -->
  469. <h3>最新问答</h3>
  470. <div class="zuixin-bowen">
  471. <div class="bowen">
  472. <a href="">请教Think PHP安装问题</a>
  473. <a href="">2020-04-14</a>
  474. </div>
  475. <div class="bowen">
  476. <a href="">请教Think PHP安装问题</a>
  477. <a href="">2020-04-14</a>
  478. </div>
  479. <div class="bowen">
  480. <a href="">请教Think PHP安装问题</a>
  481. <a href="">2020-04-14</a>
  482. </div>
  483. <div class="bowen">
  484. <a href="">请教Think PHP安装问题</a>
  485. <a href="">2020-04-14</a>
  486. </div>
  487. <div class="bowen">
  488. <a href="">请教Think PHP安装问题</a>
  489. <a href="">2020-04-14</a>
  490. </div>
  491. </div>
  492. <div class="gengduo">
  493. <a href="">更多内容</a>
  494. </div>
  495. <!-- 页脚 -->
  496. <footer>
  497. <div>
  498. <a href=""><span class="iconfont"></span></a>
  499. <a href="">首页</a>
  500. </div>
  501. <div>
  502. <a href=""><span class="iconfont"></span></a>
  503. <a href="">视频</a>
  504. </div>
  505. <div>
  506. <a href=""><span class="iconfont"></span></a>
  507. <a href="">社区</a>
  508. </div>
  509. <div>
  510. <a href=""><span class="iconfont"></span></a>
  511. <a href="">我的</a>
  512. </div>
  513. </footer>
  514. </body>
  515. </html>

效果图

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:看上去还不错哟
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
Author's latest blog post