博客列表 >CSS - 利用flex布局仿PHP中文网移动站

CSS - 利用flex布局仿PHP中文网移动站

晴天
晴天原创
2020年04月13日 14:42:17867浏览

演示站:http://php.rc238.cn/0410

效果图

源码下载地址
http://php.rc238.cn/0410/0410.rar
HTML部分

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <link rel="stylesheet" href="index.css" />
  7. <title>PHP中文网</title>
  8. </head>
  9. <body>
  10. <!-- 顶部导航区 -->
  11. <header>
  12. <nav>
  13. <a href="https://m.php.cn/member/387631.html">
  14. <span class="iconfont big">&#xe634;</span>
  15. </a>
  16. </nav>
  17. <nav>
  18. <a href="https://m.php.cn">
  19. <img src="https://m.php.cn/static/images/logo.png" alt="php.logo" />
  20. </a>
  21. </nav>
  22. <nav>
  23. <button class="iconfont big" onclick="turn()">
  24. &#xe64f;
  25. </button>
  26. </nav>
  27. </header>
  28. <!-- 侧边栏 -->
  29. <aside id="aside">
  30. <section onclick="turnoff()"></section>
  31. <section>
  32. <div>
  33. <button class="iconfont white" onclick="turnoff()">
  34. &#xe64f;
  35. </button>
  36. <span>PHP中文网</span>
  37. </div>
  38. <div>
  39. <a href="https://m.php.cn/">
  40. <div>
  41. <span class="iconfont navicon">&#xe607;</span>
  42. </div>
  43. <p>首页</p>
  44. </a>
  45. <a href="https://m.php.cn/course.html">
  46. <div>
  47. <span class="iconfont navicon">&#xe609;</span>
  48. </div>
  49. <p>课程</p>
  50. </a>
  51. <a href="https://m.php.cn/article.html">
  52. <div>
  53. <span class="iconfont navicon">&#xe624;</span>
  54. </div>
  55. <p>文章</p>
  56. </a>
  57. </div>
  58. <div>
  59. <a href="https://m.php.cn/wenda.html">
  60. <div>
  61. <span class="iconfont navicon">&#xe703;</span>
  62. </div>
  63. <p>问答</p>
  64. </a>
  65. <a href="https://m.php.cn/blog.html">
  66. <div>
  67. <span class="iconfont navicon">&#xe67a;</span>
  68. </div>
  69. <p>博客</p>
  70. </a>
  71. <a href="https://m.php.cn/dic.html">
  72. <div>
  73. <span class="iconfont navicon">&#xe899;</span>
  74. </div>
  75. <p>词典</p>
  76. </a>
  77. </div>
  78. <div>
  79. <a href="https://m.php.cn/course/type/99.html">
  80. <div>
  81. <span class="iconfont navicon">&#xe898; </span>
  82. </div>
  83. <p>手册</p>
  84. </a>
  85. <a href="https://www.php.cn/xiazai/">
  86. <div>
  87. <span class="iconfont navicon">&#xeee8;</span>
  88. </div>
  89. <p>资源</p>
  90. </a>
  91. <a href="https://m.php.cn/search">
  92. <div>
  93. <span class="iconfont navicon">&#xe64b;</span>
  94. </div>
  95. <p>搜索</p>
  96. </a>
  97. </div>
  98. </section>
  99. </aside>
  100. <!-- 主体区 -->
  101. <main>
  102. <!-- 1轮播图 -->
  103. <section>
  104. <a href="https://m.php.cn/wenda/160048.html">
  105. <img src="https://m.php.cn/static/images/ico/3.jpg" alt="lunbop.jpg"
  106. /></a>
  107. </section>
  108. <!-- 2分类区 -->
  109. <section>
  110. <!-- 第一行 -->
  111. <div>
  112. <div>
  113. <a href="https://m.php.cn/course/list/1.html">
  114. <div>
  115. <span class="iconfont navbig">&#xe6a0;</span>
  116. </div>
  117. <p>HTML/CSS</p>
  118. </a>
  119. </div>
  120. <div>
  121. <a href="https://m.php.cn/course/list/2.html">
  122. <div>
  123. <span class="iconfont navbig">&#xe810;</span>
  124. </div>
  125. <p>JavaScript</p>
  126. </a>
  127. </div>
  128. <div>
  129. <a href="https://m.php.cn/course/list/3.html">
  130. <div>
  131. <span class="iconfont navbig">&#xe601;</span>
  132. </div>
  133. <p>服务端</p>
  134. </a>
  135. </div>
  136. <div>
  137. <a href="https://m.php.cn/course/list/4.html">
  138. <div>
  139. <span class="iconfont navbig">&#xe625;</span>
  140. </div>
  141. <p>数据库</p></a
  142. >
  143. </div>
  144. </div>
  145. <!-- 第二行 -->
  146. <div>
  147. <div>
  148. <a href="https://m.php.cn/course/list/5.html">
  149. <div>
  150. <span class="iconfont navbig">&#xe63f;</span>
  151. </div>
  152. <p>移动端</p></a
  153. >
  154. </div>
  155. <div>
  156. <a href="https://m.php.cn/course/type/3.html">
  157. <div>
  158. <span class="iconfont navbig">&#xe898;</span>
  159. </div>
  160. <p>手册</p></a
  161. >
  162. </div>
  163. <div>
  164. <a href="https://m.php.cn/course/list/9.html">
  165. <div>
  166. <span class="iconfont navbig">&#xe668;</span>
  167. </div>
  168. <p>工具</p>
  169. </a>
  170. </div>
  171. <div>
  172. <a href="https://m.php.cn/course/list/8.html">
  173. <div>
  174. <span class="iconfont navbig">&#xe60d;</span>
  175. </div>
  176. <p>直播</p></a
  177. >
  178. </div>
  179. </div>
  180. </section>
  181. <!-- 3推荐课程 -->
  182. <section>
  183. <p>推荐课程</p>
  184. <!-- 双图区 -->
  185. <div>
  186. <a href="https://m.php.cn/course/797.html">
  187. <div>
  188. <img
  189. src="https://img.php.cn/upload/course/000/000/001/5d242759adb88970.jpg"
  190. alt="wechat.jpg"
  191. />
  192. </div>
  193. </a>
  194. <a href="https://m.php.cn/course/801.html">
  195. <div>
  196. <img
  197. src="https://img.php.cn/upload/course/000/000/001/5d2426f409839992.jpg"
  198. alt="aiqiyi.jpg"
  199. />
  200. </div>
  201. </a>
  202. </div>
  203. <!-- ci框架极速入门 -->
  204. <div>
  205. <div>
  206. <a href="https://m.php.cn/course/760.html">
  207. <img
  208. src="https://img.php.cn/upload/course/000/000/035/5d2941e265889366.jpg"
  209. alt="jisu.jpg"
  210. />
  211. </a>
  212. </div>
  213. <div>
  214. <a href="https://m.php.cn/course/760.html">CI框架30分钟极速入门</a>
  215. <div>
  216. <span>中级</span>
  217. <span>61234次播放</span>
  218. </div>
  219. </div>
  220. </div>
  221. <!-- 前端入门 -->
  222. <div>
  223. <div>
  224. <a href="https://m.php.cn/course/880.html">
  225. <img
  226. src="https://img.php.cn/upload/course/000/126/153/5aa23f0ded921649.jpg"
  227. alt=""
  228. />
  229. </a>
  230. </div>
  231. <div>
  232. <a href="https://m.php.cn/course/880.html">2018前端入门_HTML5</a>
  233. <div>
  234. <span>初级</span>
  235. <span>310025次播放</span>
  236. </div>
  237. </div>
  238. </div>
  239. </section>
  240. <!-- 4最新更新 -->
  241. <section>
  242. <p>最新更新</p>
  243. <div>
  244. <div>
  245. <a href="https://m.php.cn/course/1087.html"
  246. ><img
  247. src="https://img.php.cn/upload/course/000/000/015/5e0d6387e45cc764.png"
  248. alt=""
  249. /></a>
  250. </div>
  251. <div>
  252. <a href="https://m.php.cn/course/1087.html"
  253. >PHP快速操控Excel之PhpSpreadsheet</a
  254. >
  255. <p>
  256. 老的PHPExcel已经停止更新了!目前最新的是使用phpOffice插件PhpSpreadsheet,用纯
  257. php
  258. 编写的库,它提供了一组类,允许您读取和写入不同的电子表格文件格式!php中文网欧阳克老师原创课程!注:PHP运行环境需要PHP7.1以上
  259. </p>
  260. <div>
  261. <span>中级</span>
  262. <span>14960次播放</span>
  263. </div>
  264. </div>
  265. </div>
  266. <div>
  267. <div>
  268. <a href=""
  269. ><img
  270. src="https://img.php.cn/upload/course/000/000/015/5e0d82773b4fe808.png"
  271. alt=""
  272. /></a>
  273. </div>
  274. <div>
  275. <a href="https://m.php.cn/course/1086.html"
  276. >Thinkphp6.0正式版视频教程</a
  277. >
  278. <p>
  279. Thinkphp6.0从2019年10月24日正式发布,相对测试版,有很多变动,目前TP6已经相对比较稳定了,所以php中文网在2020年再次重新录制课程,帮助快速入门!相关推荐:
  280. ThinkPHP6.0完全开发手册(注解版)
  281. https://www.php.cn/course/1049.html
  282. </p>
  283. <div><span>中级</span><span>48767次播放</span></div>
  284. </div>
  285. </div>
  286. <div>
  287. <div>
  288. <a href=""
  289. ><img
  290. src="https://img.php.cn/upload/course/000/000/014/5db2b53c67bca626.jpg"
  291. alt=""
  292. /></a>
  293. </div>
  294. <div>
  295. <a href="https://m.php.cn/course/1078.html">2019python自学视频</a>
  296. <p>
  297. 本课程适合想从零开始学习 Python
  298. 编程语言的开发人员。由浅入深的带你进入python世界,自学python的一份好课程,兄弟连课程
  299. </p>
  300. <div><span>初级</span><span>36301次播放</span></div>
  301. </div>
  302. </div>
  303. <div>
  304. <div>
  305. <a href=""
  306. ><img
  307. src="https://img.php.cn/upload/course/000/000/015/5da7e9b7895ed229.png"
  308. alt=""
  309. /></a>
  310. </div>
  311. <div>
  312. <a href="https://m.php.cn/course/1077.html"
  313. >PHP开发免费公益直播课</a
  314. >
  315. <p>
  316. 主讲:php中文网-朱老师( Peter Zhu) 时间:2019.10.17 晚 20:00-22:00
  317. 主题:如何高效的学习一门新技术? 具体内容:1. 2020了,
  318. 还有哪些值得学习的新技术? 2.如何高效的学习前端开发?
  319. 3.如果高效的学习PHP开发?4.phpStudy V8 新功能介绍与演示
  320. 5.小皮面板功能介绍
  321. </p>
  322. <div><span>初级</span><span>6805次播放</span></div>
  323. </div>
  324. </div>
  325. <div>
  326. <div>
  327. <a href=""
  328. ><img
  329. src="https://img.php.cn/upload/course/000/000/014/5da6a50535529903.jpg"
  330. alt=""
  331. /></a>
  332. </div>
  333. <div>
  334. <a href="https://m.php.cn/course/1076.html"
  335. >从零开始到WEB响应式布局</a
  336. >
  337. <p>
  338. 重点介绍了HTML、CSS、web布局前端核心技术,通过视频讲解,了解可以利用HTML+CSS做什么,有相关工具、后端语言,逻辑思维训练等知识点
  339. </p>
  340. <div><span>初级</span><span>29063次播放</span></div>
  341. </div>
  342. </div>
  343. <div>
  344. <div>
  345. <a href=""
  346. ><img
  347. src="https://img.php.cn/upload/course/000/000/015/5da51b8ff1224244.png"
  348. alt=""
  349. /></a>
  350. </div>
  351. <div>
  352. <a href="https://m.php.cn/course/1075.html">PHP文件基础操作</a>
  353. <p>
  354. 好多同学在PHP基础的时候对PHP文件的操作了解的不够多,本节课就带着大家来学习PHP文件的基础操作,PHP操作文件主要用到的就是PHP文件相关的函数,那么我们主要讲的也就是PHP文件相关的各种函数,相信本节课程会让你对PHP更感兴趣哦!
  355. </p>
  356. <div><span>中级</span><span>8837次播放</span></div>
  357. </div>
  358. </div>
  359. </section>
  360. <!-- 5最新文章 -->
  361. <section>
  362. <p>最新文章</p>
  363. <div>
  364. <div>
  365. <a href="https://m.php.cn/tool/sublime/447028.html">
  366. <p>sublime正则搜索替换修改数据的方法</p>
  367. <p>发布时间:2020-04-11</p>
  368. </a>
  369. </div>
  370. <div>
  371. <a href="https://m.php.cn/tool/sublime/447028.html"
  372. ><img
  373. src="https://img.php.cn/upload/article/000/000/020/5e91923747dab842.jpg"
  374. alt=""
  375. /></a>
  376. </div>
  377. </div>
  378. <div>
  379. <div>
  380. <a href="https://m.php.cn/faq/447027.html">
  381. <p>为什么我的电脑只有c盘</p>
  382. <p>发布时间:2020-04-11</p></a
  383. >
  384. </div>
  385. <div>
  386. <a href="https://m.php.cn/faq/447027.html"
  387. ><img
  388. src="https://img.php.cn/upload/article/000/000/020/5e918fffe166f364.jpg"
  389. alt=""
  390. /></a>
  391. </div>
  392. </div>
  393. <div>
  394. <div>
  395. <a href="https://m.php.cn/cms/dedecms/447026.html">
  396. <p>dedecms如何添加并引入php文件</p>
  397. <p>发布时间:2020-04-11</p>
  398. </a>
  399. </div>
  400. <div>
  401. <a href="https://m.php.cn/cms/dedecms/447026.html"
  402. ><img
  403. src="https://img.php.cn/upload/article/000/000/041/5e918a4ac6da9826.jpg"
  404. alt=""
  405. /></a>
  406. </div>
  407. </div>
  408. <div>
  409. <div>
  410. <a href="https://m.php.cn/faq/447025.html">
  411. <p>扩展分区转主分区的方法</p>
  412. <p>
  413. 发布时间:2020-04-11
  414. </p>
  415. </a>
  416. </div>
  417. <div>
  418. <a href="https://m.php.cn/faq/447025.html"
  419. ><img
  420. src="https://img.php.cn/upload/article/000/000/020/5e9179096b985669.jpg"
  421. alt=""
  422. /></a>
  423. </div>
  424. </div>
  425. <div>
  426. <div>
  427. <a href="https://m.php.cn/java/interview/447024.html">
  428. <p>2020全新Java面试题——容器(二)</p>
  429. <p>
  430. 发布时间:2020-04-11
  431. </p>
  432. </a>
  433. </div>
  434. <div>
  435. <a href="https://m.php.cn/java/interview/447024.html"
  436. ><img
  437. src="https://img.php.cn/upload/article/000/000/041/5e9172bb26057270.jpg"
  438. alt=""
  439. /></a>
  440. </div>
  441. </div>
  442. <div>
  443. <a href="https://m.php.cn/article.html">更多内容 </a>
  444. </div>
  445. </section>
  446. <!-- 6最新博文 -->
  447. <section>
  448. <p>最新博文</p>
  449. <div>
  450. <a href="https://m.php.cn/blog/detail/20557.html">
  451. <span>Jquery+AJAX上传文件,无刷新上传并重命名文件</span>
  452. <span>2020-04-11</span>
  453. </a>
  454. </div>
  455. <div>
  456. <a href="https://m.php.cn/blog/detail/20547.html">
  457. <span>thinkphp5.6源码阅读1</span>
  458. <span>2020-04-11</span>
  459. </a>
  460. </div>
  461. <div>
  462. <a href="https://m.php.cn/blog/detail/20509.html">
  463. <span>Composer windows安装详细介绍</span>
  464. <span>2020-04-11</span>
  465. </a>
  466. </div>
  467. <div>
  468. <a href="https://m.php.cn/blog/detail/20508.html">
  469. <span>AI智能电销机器人源码 源码解读(1)—基础</span>
  470. <span>2020-04-11</span>
  471. </a>
  472. </div>
  473. <div>
  474. <a href="https://m.php.cn/blog/detail/20492.html">
  475. <span>利用css过滤实现玩网页夜模式适配</span>
  476. <span>2020-04-11</span>
  477. </a>
  478. </div>
  479. <div>
  480. <a href="https://m.php.cn/blog.html">
  481. <span>更多内容</span>
  482. </a>
  483. </div>
  484. </section>
  485. <!-- 7最新问答 -->
  486. <section>
  487. <p>最新问答</p>
  488. <div>
  489. <a href="https://m.php.cn/wenda/164957.html">
  490. <span>不出现tp6.0页面</span>
  491. <span>2020-04-11</span>
  492. </a>
  493. </div>
  494. <div>
  495. <a href="https://m.php.cn/wenda/164956.html">
  496. <span>数据库密码··</span>
  497. <span>2020-04-11</span>
  498. </a>
  499. </div>
  500. <div>
  501. <a href="https://m.php.cn/wenda/164955.html">
  502. <span>制定的学习计划在哪能找到 咋找不到呢?</span>
  503. <span>2020-04-11</span>
  504. </a>
  505. </div>
  506. <div>
  507. <a href="https://m.php.cn/wenda/164954.html">
  508. <span>数据库链接后怎么知道用哪个表啊</span>
  509. <span>2020-04-11</span>
  510. </a>
  511. </div>
  512. <div>
  513. <a href="https://m.php.cn/wenda/164953.html">
  514. <span>这个同步的东西</span>
  515. <span>2020-04-11</span>
  516. </a>
  517. </div>
  518. <div>
  519. <a href="https://m.php.cn/wenda.html">
  520. <span>更多内容</span>
  521. </a>
  522. </div>
  523. </section>
  524. <!-- 底部留空 -->
  525. <div></div>
  526. </main>
  527. <!-- 底部导航区 -->
  528. <footer>
  529. <a href="">
  530. <div>
  531. <span class="iconfont foot">&#xe607;</span>
  532. <p>首页</p>
  533. </div>
  534. </a>
  535. <a href="">
  536. <div>
  537. <span class="iconfont foot">&#xe63d;</span>
  538. <p>视频</p>
  539. </div>
  540. </a>
  541. <a href="">
  542. <div>
  543. <span class="iconfont foot">&#xe67e;</span>
  544. <p>社区</p>
  545. </div>
  546. </a>
  547. <a href="">
  548. <div>
  549. <span class="iconfont foot">&#xe602;</span>
  550. <p>我的</p>
  551. </div>
  552. </a>
  553. </footer>
  554. </body>
  555. <script type="text/javascript">
  556. //改变div的css属性
  557. function turnoff() {
  558. document.getElementById("aside").style.display = "none";
  559. }
  560. function turn() {
  561. document.getElementById("aside").style.display = "flex";
  562. }
  563. </script>
  564. </html>
  • CSS 部分
  1. @font-face {
  2. font-family: "iconfont";
  3. src: url("./font_icon/iconfont.eot");
  4. src: url("./font_icon/iconfont.eot?#iefix") format("embedded-opentype"),
  5. url("./font_icon/iconfont.woff2") format("woff2"),
  6. url("./font_icon/iconfont.woff") format("woff"),
  7. url("./font_icon/iconfont.ttf") format("truetype"),
  8. url("./font_icon/iconfont.svg#iconfont") format("svg");
  9. }
  10. .iconfont {
  11. font-family: "iconfont" !important;
  12. font-size: 16px;
  13. font-style: normal;
  14. -webkit-font-smoothing: antialiased;
  15. -moz-osx-font-smoothing: grayscale;
  16. }
  17. a {
  18. text-decoration: none;
  19. color: aliceblue;
  20. }
  21. * {
  22. margin: 0;
  23. padding: 0;
  24. }
  25. html {
  26. font-size: 15px;
  27. }
  28. body {
  29. max-width: 800px;
  30. background-color: #edeff0;
  31. }
  32. /* 顶部导航区 */
  33. header {
  34. height: 5vh;
  35. background-color: #2d353c;
  36. display: flex;
  37. justify-content: space-between;
  38. align-items: center;
  39. padding: 0px 10px;
  40. position: fixed;
  41. top: 0px;
  42. width: 100vw;
  43. }
  44. header nav {
  45. margin-right: 15px;
  46. }
  47. header img {
  48. width: 60%;
  49. height: 50%;
  50. }
  51. header button {
  52. border: none;
  53. background-color: transparent;
  54. }
  55. .big {
  56. font-size: 1.5rem;
  57. color: #edeff0;
  58. }
  59. /* 侧边栏 */
  60. aside {
  61. height: 100vh;
  62. width: 100vw;
  63. position: fixed;
  64. top: 0;
  65. left: 0;
  66. display: flex;
  67. flex-flow: row nowrap;
  68. display: none;
  69. }
  70. /* 侧边栏图标 */
  71. .white {
  72. color: lightcyan;
  73. font-weight: bolder;
  74. font-size: 1.3rem;
  75. }
  76. aside > section:first-of-type {
  77. width: 35vw;
  78. background-color: black;
  79. opacity: 50%;
  80. }
  81. aside > section:last-of-type {
  82. background-color: #394148;
  83. width: 65vw;
  84. }
  85. /* 右边导航区 */
  86. /* 第一行 */
  87. aside > section:last-of-type > div:first-of-type {
  88. display: flex;
  89. flex-flow: row nowrap;
  90. justify-content: space-around;
  91. height: 6vh;
  92. align-items: center;
  93. }
  94. aside > section:last-of-type > div:first-of-type > button {
  95. border: none;
  96. background-color: transparent;
  97. }
  98. aside > section:last-of-type > div:first-of-type > span {
  99. width: 38vw;
  100. font-size: 1.4rem;
  101. color: #c0c2c3;
  102. font-weight: 600;
  103. }
  104. /* 排除第一行 */
  105. aside > section:last-of-type > div:not(:first-of-type) {
  106. display: flex;
  107. flex-flow: row nowrap;
  108. height: 15vh;
  109. width: 100%;
  110. justify-content: space-around;
  111. }
  112. aside > section:last-of-type > div:not(:first-of-type) > a {
  113. display: flex;
  114. flex-flow: column nowrap;
  115. align-items: center;
  116. width: 25%;
  117. }
  118. aside > section:last-of-type > div:not(:first-of-type) > a > p {
  119. margin: auto;
  120. font-size: 1rem;
  121. color: #cfcfcf;
  122. }
  123. aside > section:last-of-type > div:not(:first-of-type) > a > div {
  124. width: 58px;
  125. height: 58px;
  126. border: none;
  127. border-radius: 27px;
  128. margin-top: 10px;
  129. display: flex;
  130. flex-flow: row nowrap;
  131. justify-content: center;
  132. align-items: center;
  133. }
  134. /* 导航区图标 */
  135. .navicon {
  136. font-size: 2.5rem;
  137. font-weight: bolder;
  138. }
  139. /* 第二行图标颜色 */
  140. aside > section:last-of-type > div:nth-of-type(2) > a:first-of-type > div {
  141. background-color: #57c98a;
  142. }
  143. aside > section:last-of-type > div:nth-of-type(2) > a:nth-of-type(2) > div {
  144. background-color: #fe9728;
  145. }
  146. aside > section:last-of-type > div:nth-of-type(2) > a:last-of-type > div {
  147. background-color: #4dd0e1;
  148. }
  149. /* 第三行图标颜色 */
  150. aside > section:last-of-type > div:nth-of-type(3) > a:first-of-type > div {
  151. background-color: #64b5f6;
  152. }
  153. aside > section:last-of-type > div:nth-of-type(3) > a:nth-of-type(2) > div {
  154. background-color: #119b8e;
  155. }
  156. aside > section:last-of-type > div:nth-of-type(3) > a:last-of-type > div {
  157. background-color: #fe9728;
  158. }
  159. /* 第四行图标颜色 */
  160. aside > section:last-of-type > div:nth-of-type(4) > a:first-of-type > div {
  161. background-color: #ff8a65;
  162. }
  163. aside > section:last-of-type > div:nth-of-type(4) > a:nth-of-type(2) > div {
  164. background-color: #ffb74d;
  165. }
  166. aside > section:last-of-type > div:nth-of-type(4) > a:last-of-type > div {
  167. background-color: #ef8383;
  168. }
  169. /* 内容主体 */
  170. main {
  171. display: flex;
  172. flex-flow: column nowrap;
  173. width: 100vw;
  174. }
  175. main > section:first-of-type img {
  176. width: 100%;
  177. }
  178. main > section:nth-of-type(2) {
  179. margin-top: -3px;
  180. display: flex;
  181. background-color: #fff;
  182. flex-flow: column nowrap;
  183. }
  184. main > section:nth-of-type(2) > div {
  185. display: flex;
  186. flex-flow: row nowrap;
  187. height: 13vh;
  188. width: 98vw;
  189. justify-content: space-evenly;
  190. }
  191. main > section:nth-of-type(2) > div > div {
  192. margin-top: 5px;
  193. width: 80px;
  194. height: 80px;
  195. text-align: center;
  196. }
  197. main > section:nth-of-type(2) > div > div div {
  198. width: 50px;
  199. height: 50px;
  200. border-radius: 18px;
  201. margin: auto;
  202. display: flex;
  203. justify-content: center;
  204. }
  205. main > section:nth-of-type(2) div > div > a > div > span {
  206. align-self: center;
  207. }
  208. main > section:nth-of-type(2) p {
  209. margin-top: 5px;
  210. color: #888888;
  211. font-weight: bold;
  212. font-family: sans-serif;
  213. }
  214. .navbig {
  215. color: mintcream;
  216. font-size: 2rem;
  217. }
  218. main > section:nth-of-type(2) > div > div:first-of-type div {
  219. background-color: #81a7f2;
  220. text-align: center;
  221. }
  222. main > section:nth-of-type(2) > div > div:nth-of-type(2) div {
  223. background-color: #f47a71;
  224. text-align: center;
  225. }
  226. main > section:nth-of-type(2) > div > div:nth-of-type(3) div {
  227. background-color: #ee9139;
  228. text-align: center;
  229. }
  230. main > section:nth-of-type(2) > div > div:nth-of-type(4) div {
  231. background-color: #7ab9f6;
  232. text-align: center;
  233. }
  234. main > section:nth-of-type(2) > div > div:nth-of-type(5) div {
  235. background-color: #956fcd;
  236. text-align: center;
  237. }
  238. main > section:nth-of-type(2) > div > div:nth-of-type(6) div {
  239. background-color: #57c1ee;
  240. text-align: center;
  241. }
  242. main > section:nth-of-type(2) > div > div:nth-of-type(7) div {
  243. background-color: #f57d77;
  244. text-align: center;
  245. }
  246. main > section:nth-of-type(2) > div > div:last-of-type div {
  247. background-color: #84aaf2;
  248. text-align: center;
  249. }
  250. /* 推荐课程 */
  251. /* 主体样式 */
  252. main > section:nth-of-type(3) {
  253. width: 95vw;
  254. margin: auto;
  255. margin-top: 10px;
  256. display: flex;
  257. flex-flow: column nowrap;
  258. }
  259. main > section:nth-of-type(3) p {
  260. color: #888888;
  261. font-family: sans-serif;
  262. font-weight: bolder;
  263. font-size: 1.3rem;
  264. }
  265. /* 后代元素 样式 */
  266. main > section:nth-of-type(3) > div {
  267. margin-top: 10px;
  268. }
  269. /* 双图元素 */
  270. main > section:nth-of-type(3) > div:first-of-type {
  271. display: flex;
  272. flex-flow: row nowrap;
  273. justify-content: space-between;
  274. }
  275. main > section:nth-of-type(3) > div:first-of-type div {
  276. width: 42vw;
  277. }
  278. main > section:nth-of-type(3) > div:first-of-type div img {
  279. width: 100%;
  280. }
  281. /* 排除第一个div元素 */
  282. main > section:nth-of-type(3) > div:not(:first-of-type) {
  283. background-color: #fff;
  284. display: flex;
  285. flex-flow: row nowrap;
  286. justify-content: space-around;
  287. }
  288. main > section:nth-of-type(3) > div:not(:first-of-type) > div:first-of-type {
  289. width: 35vw;
  290. display: flex;
  291. align-items: center;
  292. }
  293. main
  294. > section:nth-of-type(3)
  295. > div:not(:first-of-type)
  296. > div:first-of-type
  297. img {
  298. width: 100%;
  299. }
  300. main > section:nth-of-type(3) > div:not(:first-of-type) > div:last-of-type {
  301. width: 50vw;
  302. padding-top: 5px;
  303. }
  304. main > section:nth-of-type(3) > div:not(:first-of-type) > div:last-of-type a {
  305. color: #888888;
  306. font-size: 1.1rem;
  307. font-family: sans-serif;
  308. font-weight: 300;
  309. }
  310. main > section:nth-of-type(3) > div:not(:first-of-type) > div:last-of-type div {
  311. margin-top: 8px;
  312. }
  313. main
  314. > section:nth-of-type(3)
  315. > div:not(:first-of-type)
  316. > div:last-of-type
  317. span:first-of-type {
  318. border-radius: 5px;
  319. padding: 2px;
  320. background-color: #595757;
  321. color: #fff;
  322. font-size: 0.9rem;
  323. }
  324. main
  325. > section:nth-of-type(3)
  326. > div:not(:first-of-type)
  327. > div:last-of-type
  328. span:last-of-type {
  329. color: #888888;
  330. font-size: 0.8rem;
  331. }
  332. /* 最新更新 */
  333. main > section:nth-of-type(4) {
  334. width: 95vw;
  335. margin: auto;
  336. margin-top: 10px;
  337. display: flex;
  338. flex-flow: column nowrap;
  339. }
  340. main > section:nth-of-type(4) p {
  341. color: #888888;
  342. font-family: sans-serif;
  343. font-weight: bolder;
  344. font-size: 1.3rem;
  345. }
  346. main > section:nth-of-type(4) > div {
  347. background-color: #fff;
  348. display: flex;
  349. flex-flow: row nowrap;
  350. justify-content: space-around;
  351. margin-top: 15px;
  352. }
  353. main > section:nth-of-type(4) > div > div:first-of-type {
  354. width: 35vw;
  355. }
  356. main > section:nth-of-type(4) > div > div:first-of-type img {
  357. width: 100%;
  358. }
  359. main > section:nth-of-type(4) > div > div:last-of-type {
  360. width: 50vw;
  361. margin-top: 5px;
  362. display: flex;
  363. flex-flow: column nowrap;
  364. justify-content: space-around;
  365. }
  366. main > section:nth-of-type(4) > div > div:last-of-type a {
  367. color: #888888;
  368. font-size: 1.1rem;
  369. font-family: sans-serif;
  370. font-weight: 300;
  371. white-space: nowrap;
  372. overflow: hidden; /* 内容超出宽度时隐藏超出部分的内容 */
  373. text-overflow: ellipsis;
  374. }
  375. main > section:nth-of-type(4) > div > div:last-of-type p {
  376. color: #888888;
  377. font-size: 0.8rem;
  378. font-family: sans-serif;
  379. font-weight: 300;
  380. white-space: nowrap;
  381. overflow: hidden; /* 内容超出宽度时隐藏超出部分的内容 */
  382. text-overflow: ellipsis;
  383. }
  384. main > section:nth-of-type(4) > div > div:last-of-type > div {
  385. display: flex;
  386. flex-flow: row nowrap;
  387. justify-content: space-between;
  388. width: 90%;
  389. }
  390. main
  391. > section:nth-of-type(4)
  392. > div
  393. > div:last-of-type
  394. > div
  395. > span:first-of-type {
  396. padding: 0px 2px;
  397. background-color: #595757;
  398. color: #fff;
  399. border-radius: 5px;
  400. font-size: 0.9rem;
  401. }
  402. main
  403. > section:nth-of-type(4)
  404. > div
  405. > div:last-of-type
  406. > div
  407. > span:last-of-type {
  408. color: #888888;
  409. font-size: 0.8rem;
  410. }
  411. /* 最新文章 */
  412. main > section:nth-of-type(5) {
  413. margin: auto;
  414. display: flex;
  415. flex-flow: column nowrap;
  416. }
  417. main > section:nth-of-type(5) > p {
  418. color: #888888;
  419. font-family: sans-serif;
  420. font-weight: bolder;
  421. font-size: 1.3rem;
  422. margin: 10px 10px;
  423. }
  424. main > section:nth-of-type(5) > div {
  425. display: flex;
  426. flex-flow: row nowrap;
  427. justify-content: space-evenly;
  428. height: 10vh;
  429. background-color: #fff;
  430. margin-bottom: 6px;
  431. width: 95vw;
  432. }
  433. main > section:nth-of-type(5) > div > div:first-of-type {
  434. padding: 10px 10px;
  435. width: 55vw;
  436. }
  437. main > section:nth-of-type(5) > div > div:first-of-type > a > p:first-of-type {
  438. white-space: nowrap;
  439. overflow: hidden;
  440. text-overflow: ellipsis;
  441. font-size: 0.8rem;
  442. font-weight: bolder;
  443. color: #888888;
  444. margin-bottom: 5px;
  445. }
  446. main > section:nth-of-type(5) > div > div:first-of-type > a > p:last-of-type {
  447. white-space: nowrap;
  448. overflow: hidden;
  449. text-overflow: ellipsis;
  450. color: #888888;
  451. font-size: 0.8rem;
  452. }
  453. main > section:nth-of-type(5) > div > div:last-of-type {
  454. width: 30vw;
  455. display: flex;
  456. flex-flow: column nowrap;
  457. justify-content: center;
  458. }
  459. main > section:nth-of-type(5) > div > div:last-of-type img {
  460. width: 100%;
  461. max-height: 9vh;
  462. }
  463. main > section:nth-of-type(5) > div:last-of-type {
  464. height: 4vh;
  465. text-align: center;
  466. }
  467. main > section:nth-of-type(5) > div:last-of-type > a {
  468. color: #888888;
  469. margin: auto;
  470. font-weight: bolder;
  471. }
  472. /* 选中倒数两个 */
  473. main > section:nth-last-of-type(-n + 2) {
  474. display: flex;
  475. flex-flow: column nowrap;
  476. width: 95vw;
  477. margin: auto;
  478. }
  479. main > section:nth-last-of-type(-n + 2) > p {
  480. color: #888888;
  481. font-family: sans-serif;
  482. font-weight: bolder;
  483. font-size: 1.3rem;
  484. margin: 10px 10px;
  485. }
  486. main > section:nth-last-of-type(-n + 2) > div {
  487. background-color: #fff;
  488. margin-bottom: 10px;
  489. }
  490. main > section:nth-last-of-type(-n + 2) > div > a {
  491. height: 6vh;
  492. display: flex;
  493. flex-flow: row nowrap;
  494. align-items: center;
  495. justify-content: space-around;
  496. color: #888888;
  497. }
  498. main > section:nth-last-of-type(-n + 2) > div > a > span:first-of-type {
  499. width: 65vw;
  500. font-size: 1rem;
  501. font-weight: bolder;
  502. white-space: nowrap;
  503. overflow: hidden;
  504. text-overflow: ellipsis;
  505. }
  506. main > section:nth-last-of-type(-n + 2) > div:last-of-type > a {
  507. text-align: center;
  508. height: 4vh;
  509. font-weight: 100;
  510. }
  511. /* 底部留空 */
  512. main > div:last-of-type {
  513. height: 8vh;
  514. }
  515. /* 底部导航 */
  516. footer {
  517. display: flex;
  518. flex-flow: row nowrap;
  519. justify-content: space-around;
  520. width: 100vw;
  521. height: 5.5vh;
  522. background-color: #eeeeee;
  523. border-top: 1px solid lightgrey;
  524. position: fixed;
  525. bottom: 0px;
  526. text-align: center;
  527. margin: auto;
  528. padding: 5px 0px;
  529. }
  530. footer div {
  531. width: 23vw;
  532. }
  533. footer > a {
  534. text-decoration: none;
  535. color: #595757;
  536. }
  537. footer > a:first-of-type {
  538. text-decoration: none;
  539. color: #ff0000;
  540. }
  541. .foot {
  542. font-weight: bolder;
  543. }

总结

实战巩固了所学内容,从刚开始敲代码的频频翻看笔记,到后面的行云流水,仿佛一切都是那么的理所当然。充分利用flex的布局方式,或水平或垂直,或允许换行或不允许换行。再设置项目主轴对齐方式 交叉轴对齐方式。还有图标的运用 字体属性,等等。。

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议