Blogger Information
Blog 4
fans 0
comment 1
visits 2311
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
使用flex弹性盒子模拟布局移动端首页
Neo( -᷅_-᷄ )
Original
635 people have browsed it

演示地址:http://php.xmkuyue.com/zuoye/mphp.html
html示例代码:

  1. <!DOCTYPE html>
  2. <html lang="ch-zn">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <link rel="stylesheet" href="./static/css2/font-icon.css" />
  7. <link rel="icon" href="./static/img/logo.png">
  8. <title>php中文网移动端首页</title>
  9. </head>
  10. <style>
  11. /* 初始化 */
  12. * {
  13. margin: 0;
  14. padding: 0;
  15. }
  16. a {
  17. text-decoration: none;
  18. color: #888;
  19. }
  20. html {
  21. width: 100vw;
  22. height: 100vh;
  23. font-size: 14px;}
  24. body {
  25. min-width: 360px;
  26. background-color: #EDEFF0;
  27. display: flex;
  28. flex-flow: column nowrap;
  29. }
  30. /* 页眉 */
  31. body > header {
  32. background-color: #2d353c;
  33. color: white;
  34. height: 40px;
  35. display: flex;
  36. justify-content: space-between;
  37. align-items: center;
  38. padding: 0 15px;
  39. position: fixed;
  40. width: 94vw;
  41. }
  42. header > .iconfont {
  43. font-size: 1.5rem;
  44. }
  45. /* 轮播图 */
  46. body > .slider {
  47. height: 180px;
  48. }
  49. body > .slider >img {
  50. width: 100%;
  51. margin-top: 40px;
  52. }
  53. /* 主导航区 */
  54. nav {
  55. height: 170px;
  56. display: flex;
  57. flex-flow: row wrap;
  58. background-color: white;
  59. box-sizing: border-box;
  60. margin-bottom: 10px;
  61. }
  62. nav > div {
  63. width: 25vw;
  64. display: flex;
  65. flex-flow: column nowrap;
  66. align-items: center;
  67. font-size: 0.9rem;
  68. }
  69. nav > div > a:first-of-type {
  70. text-align: center;
  71. }
  72. nav > div img {
  73. width: 50%;
  74. margin-top: 10px;
  75. }
  76. /* 推荐课程 */
  77. /* 标题 */
  78. .title {
  79. font-size: 1.3rem;
  80. color: #888;
  81. padding-left: 10px;
  82. margin-top: 25px;
  83. box-sizing: border-box;
  84. }
  85. /* 轮播图 */
  86. .r-banner {
  87. margin-top: 6px;
  88. display: flex;
  89. }
  90. .r-banner > a > img {
  91. width: 50vw;
  92. padding: 5px;
  93. box-sizing: border-box;
  94. }
  95. /* 推荐课程第二部分 */
  96. .r-course {
  97. background-color: white;
  98. margin: 15px 10px 10px;
  99. display: flex;
  100. flex-flow: column nowrap;
  101. }
  102. .r-course-desc > a > img {
  103. width: 40vw;
  104. }
  105. .r-course-desc {
  106. display: flex;
  107. margin: 10px;
  108. }
  109. .r-course-desc > a:last-of-type {
  110. padding-left: 10px;
  111. font-size: 1.1rem;
  112. }
  113. /* 最新更新 */
  114. .new-course {
  115. display: flex;
  116. flex-flow: column nowrap;
  117. margin:10px 10px 0;
  118. }
  119. .n-course {
  120. display: flex;
  121. flex-flow: row nowrap;
  122. margin-bottom:10px;
  123. padding: 10px;
  124. background-color: white;
  125. }
  126. .n-course > a > img {
  127. width: 40vw;
  128. }
  129. .n-course-desc {
  130. display: flex;
  131. flex-flow: column nowrap;
  132. padding-left: 10px;
  133. }
  134. .n-course-desc > a:last-of-type{
  135. font-size: 0.8rem;
  136. padding-top: 15px;
  137. }
  138. /* 最新文章 */
  139. .new-article {
  140. display: flex;
  141. flex-flow: column nowrap;
  142. margin: 10px;
  143. }
  144. .n-article > a > img {
  145. width: 25vw;
  146. height: 10vh;
  147. }
  148. .n-article {
  149. background-color: white;
  150. margin-bottom: 10px;
  151. padding: 10px 10px 10px;
  152. display: flex;
  153. }
  154. .new-article-desc {
  155. display: flex;
  156. flex-flow: column nowrap;
  157. width: 65vw;
  158. height: 80px;
  159. }
  160. .new-article-desc > a:last-of-type {
  161. font-size: 0.8rem;
  162. margin-top: 10px;
  163. }
  164. /* 最新博文 */
  165. .bowen {
  166. display: flex;
  167. flex-flow: column nowrap;
  168. }
  169. .desc {
  170. display: flex;
  171. background-color: white;
  172. margin: 10px 10px 0;
  173. height: 35px;
  174. justify-content: space-between;
  175. padding: 10px;
  176. }
  177. /* 最新问答 */
  178. .answer {
  179. display: flex;
  180. flex-flow: column nowrap;
  181. }
  182. .answerdesc {
  183. display: flex;
  184. background-color: white;
  185. margin: 10px 10px 0;
  186. height: 35px;
  187. justify-content: space-between;
  188. padding: 10px;
  189. }
  190. .answerdesc:last-of-type {
  191. margin-bottom: 60px;
  192. }
  193. /* 底部菜单 */
  194. footer {
  195. display: flex;
  196. justify-content: space-around;
  197. background-color: #EDEFF0;
  198. width: 100vw;
  199. height: 50px;
  200. position:fixed;
  201. bottom: 0;
  202. align-items: center;
  203. border-top: 1px solid #8888;
  204. }
  205. .downnav {
  206. display: flex;
  207. flex-flow: column nowrap;
  208. text-align: center;
  209. font-size: 1.1rem;
  210. }
  211. .downnav > a:hover {
  212. color: coral;
  213. }
  214. .iconfont {
  215. font-size: 1.5rem;
  216. }
  217. </style>
  218. <body>
  219. <!-- 页眉 -->
  220. <header>
  221. <span class="iconfont"> &#xe620;</span>
  222. <a href=""><img src="./static/img/logo.png" alt="" width="100" /></a>
  223. <span class="iconfont"> &#xe67c;</span>
  224. </header>
  225. <!-- 轮播图 -->
  226. <div class="slider">
  227. <img src="./static/img/banner1.jpg" alt="" />
  228. </div>
  229. <!-- 主导航区 -->
  230. <nav>
  231. <div>
  232. <a href=""><img src="./static/img/nav1.png" alt="" /></a>
  233. <a href="">HTML/CSS</a>
  234. </div>
  235. <div>
  236. <a href=""><img src="./static/img/nav2.png" alt="" /></a>
  237. <a href="">JavaScript</a>
  238. </div>
  239. <div>
  240. <a href=""><img src="./static/img/nav3.png" alt="" /></a>
  241. <a href="">服务端</a>
  242. </div>
  243. <div>
  244. <a href=""><img src="./static/img/nav4.png" alt="" /></a>
  245. <a href="">数据库</a>
  246. </div>
  247. <div>
  248. <a href=""><img src="./static/img/nav5.png" alt="" /></a>
  249. <a href="">移动端</a>
  250. </div>
  251. <div>
  252. <a href=""><img src="./static/img/nav6.png" alt="" /></a>
  253. <a href="">手册</a>
  254. </div>
  255. <div>
  256. <a href=""><img src="./static/img/nav7.png" alt="" /></a>
  257. <a href="">工具</a>
  258. </div>
  259. <div>
  260. <a href=""><img src="./static/img/nav8.png" alt="" /></a>
  261. <a href="">直播</a>
  262. </div>
  263. </nav>
  264. <!-- 推荐课程 -->
  265. <h2 class="title">推荐课程</h2>
  266. <div class="recommend">
  267. <div class="r-banner">
  268. <a href=""><img src="./static/img/r-banner1.jpg" alt="" /></a>
  269. <a href=""><img src="./static/img/r-banner2.jpg" alt="" /></a>
  270. </div>
  271. <div class="r-course">
  272. <div class="r-course-desc">
  273. <a href=""><img src="./static/img/r-course1.jpg" alt="" /></a>
  274. <a href="">CI框架30分钟极速入门</a>
  275. </div>
  276. </div>
  277. <div class="r-course">
  278. <div class="r-course-desc">
  279. <a href=""><img src="./static/img/r-course2.jpg" alt="" /></a>
  280. <a href="">2018前端入门_HTML5</a>
  281. </div>
  282. </div>
  283. </div>
  284. <!-- 最新更新 -->
  285. <h2 class="title">最新更新</h2>
  286. <div class="new-course">
  287. <div class="n-course">
  288. <a href=""><img src="./static/img/n-course1.png" alt="" /></a>
  289. <div class="n-course-desc">
  290. <a href="">PHP快速操控Excel</a>
  291. <a href="">老的PHPExcel已经停止更新了!</a>
  292. </div>
  293. </div>
  294. <div class="n-course">
  295. <a href=""><img src="./static/img/n-course2.png" alt="" /></a>
  296. <div class="n-course-desc">
  297. <a href="">PHP快速操控Excel</a>
  298. <a href="">老的PHPExcel已经停止更新了!</a>
  299. </div>
  300. </div>
  301. <div class="n-course">
  302. <a href=""><img src="./static/img/n-course3.png" alt="" /></a>
  303. <div class="n-course-desc">
  304. <a href="">PHP快速操控Excel</a>
  305. <a href="">老的PHPExcel已经停止更新了!</a>
  306. </div>
  307. </div>
  308. <div class="n-course">
  309. <a href=""><img src="./static/img/n-course4.png" alt="" /></a>
  310. <div class="n-course-desc">
  311. <a href="">PHP快速操控Excel</a>
  312. <a href="">老的PHPExcel已经停止更新了!</a>
  313. </div>
  314. </div>
  315. <div class="n-course">
  316. <a href=""><img src="./static/img/n-course5.png" alt="" /></a>
  317. <div class="n-course-desc">
  318. <a href="">PHP快速操控Excel</a>
  319. <a href="">老的PHPExcel已经停止更新了!</a>
  320. </div>
  321. </div>
  322. <div class="n-course">
  323. <a href=""><img src="./static/img/n-course6.png" alt="" /></a>
  324. <div class="n-course-desc">
  325. <a href="">PHP快速操控Excel</a>
  326. <a href="">老的PHPExcel已经停止更新了!</a>
  327. </div>
  328. </div>
  329. </div>
  330. <!-- 最新文章 -->
  331. <h2 class="title">最新文章</h2>
  332. <div class="new-article">
  333. <div class="n-article">
  334. <div class="new-article-desc">
  335. <a href="">为什么我的电脑只有C盘</a>
  336. <a href="">发布时间:2020-04-11</a>
  337. </div>
  338. <a href=""><img src="./static/img/n-article1.jpg" alt="" /></a>
  339. </div>
  340. <div class="n-article">
  341. <div class="new-article-desc">
  342. <a href="">为什么我的电脑只有C盘</a>
  343. <a href="">发布时间:2020-04-11</a>
  344. </div>
  345. <a href=""><img src="./static/img/n-article2.jpg" alt="" /></a>
  346. </div>
  347. <div class="n-article">
  348. <div class="new-article-desc">
  349. <a href="">为什么我的电脑只有C盘</a>
  350. <a href="">发布时间:2020-04-11</a>
  351. </div>
  352. <a href=""><img src="./static/img/n-article3.jpg" alt="" /></a>
  353. </div>
  354. <div class="n-article">
  355. <div class="new-article-desc">
  356. <a href="">为什么我的电脑只有C盘</a>
  357. <a href="">发布时间:2020-04-11</a>
  358. </div>
  359. <a href=""><img src="./static/img/n-article4.jpg" alt="" /></a>
  360. </div>
  361. <div class="n-article">
  362. <div class="new-article-desc">
  363. <a href="">为什么我的电脑只有C盘</a>
  364. <a href="">发布时间:2020-04-11</a>
  365. </div>
  366. <a href=""><img src="./static/img/n-article5.jpg" alt="" /></a>
  367. </div>
  368. </div>
  369. <!-- 最新博文 -->
  370. <h2 class="title">最新博文</h2>
  371. <div class="bowen">
  372. <div class="desc">
  373. <a href=""><strong>thinkphp5.6源码阅读1</strong></a>
  374. <a href="">2020-04-11</a>
  375. </div>
  376. <div class="desc">
  377. <a href=""><strong>thinkphp5.6源码阅读1</strong></a>
  378. <a href="">2020-04-11</a>
  379. </div>
  380. <div class="desc">
  381. <a href=""><strong>thinkphp5.6源码阅读1</strong></a>
  382. <a href="">2020-04-11</a>
  383. </div>
  384. <div class="desc">
  385. <a href=""><strong>thinkphp5.6源码阅读1</strong></a>
  386. <a href="">2020-04-11</a>
  387. </div>
  388. <div class="desc">
  389. <a href=""><strong>thinkphp5.6源码阅读1</strong></a>
  390. <a href="">2020-04-11</a>
  391. </div>
  392. </div>
  393. <!-- 最新问答 -->
  394. <h2 class="title">最新问答</h2>
  395. <div class="answer">
  396. <div class="answerdesc">
  397. <a href=""><strong>thinkphp5.6源码阅读1</strong></a>
  398. <a href="">2020-04-11</a>
  399. </div>
  400. <div class="answerdesc">
  401. <a href=""><strong>thinkphp5.6源码阅读1</strong></a>
  402. <a href="">2020-04-11</a>
  403. </div>
  404. <div class="answerdesc">
  405. <a href=""><strong>thinkphp5.6源码阅读1</strong></a>
  406. <a href="">2020-04-11</a>
  407. </div>
  408. <div class="answerdesc">
  409. <a href=""><strong>thinkphp5.6源码阅读1</strong></a>
  410. <a href="">2020-04-11</a>
  411. </div>
  412. <div class="answerdesc">
  413. <a href=""><strong>thinkphp5.6源码阅读1</strong></a>
  414. <a href="">2020-04-11</a>
  415. </div>
  416. </div>
  417. <footer>
  418. <div class="downnav">
  419. <span class="iconfont">&#xe723;</span>
  420. <a href="">首页</a>
  421. </div>
  422. <div class="downnav">
  423. <span class="iconfont">&#xe750;</span>
  424. <a href="">视频</a>
  425. </div>
  426. <div class="downnav">
  427. <span class="iconfont">&#xe67e;</span>
  428. <a href="">社区</a>
  429. </div>
  430. <div class="downnav">
  431. <span class="iconfont">&#xe602;</span>
  432. <a href="">我的</a>
  433. </div>
  434. </footer>
  435. </body>
  436. </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