博客列表 >使用flex框架仿PHP中文网手机端首页

使用flex框架仿PHP中文网手机端首页

王娇
王娇原创
2020年04月18日 15:53:33700浏览

演示链接

http://xuanransoftware.com/phpStudy/0410/

效果图

html示例代码

  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/style.css" />
  7. <title>php中文网移动端首页</title>
  8. </head>
  9. <body>
  10. <!-- 页眉部分 -->
  11. <header>
  12. <a href="" class="iconfont"></a>
  13. <a href=""><img src="images/logo.png" alt="" /></a>
  14. <a href="" class="iconfont"></a>
  15. </header>
  16. <!-- 网页主体部分 -->
  17. <main>
  18. <a href=""><img src="images/mainBanner.png" alt="" /></a>
  19. <nav>
  20. <div>
  21. <a href=""><img src="images/navHtml.png" alt="" /></a>
  22. <a href=""><span>HTML/CSS</span></a>
  23. </div>
  24. <div>
  25. <a href=""><img src="images/navJs.png" alt="" /></a>
  26. <a href=""><span>JavaScript</span></a>
  27. </div>
  28. <div>
  29. <a href=""><img src="images/navServer.png" alt="" /></a>
  30. <a href=""><span>服务端</span></a>
  31. </div>
  32. <div>
  33. <a href=""><img src="images/navDb.png" alt="" /></a>
  34. <a href=""><span>数据库</span></a>
  35. </div>
  36. <div>
  37. <a href=""><img src="images/navMobile.png" alt="" /></a>
  38. <a href=""><span>移动端</span></a>
  39. </div>
  40. <div>
  41. <a href=""><img src="images/navManual.png" alt="" /></a>
  42. <a href=""><span>手册</span></a>
  43. </div>
  44. <div>
  45. <a href=""><img src="images/navTool.png" alt="" /></a>
  46. <a href=""><span>工具</span></a>
  47. </div>
  48. <div>
  49. <a href=""><img src="images/navLive.png" alt="" /></a>
  50. <a href=""><span>直播</span></a>
  51. </div>
  52. </nav>
  53. <section class="recomCourse">
  54. <h2>推荐课程</h2>
  55. <div>
  56. <div>
  57. <a href=""><img src="images/course1.png" alt="" /></a>
  58. </div>
  59. <div>
  60. <a href=""><img src="images/course2.png" alt="" /></a>
  61. </div>
  62. </div>
  63. <div>
  64. <div>
  65. <a href=""><img src="images/course3.png" alt="" /></a>
  66. </div>
  67. <div class="desc">
  68. <a href="">CI框架30分钟极速入门</a>
  69. <div>
  70. <span>中级</span>
  71. <span>61215次播放</span>
  72. </div>
  73. </div>
  74. </div>
  75. <div>
  76. <div>
  77. <a href=""><img src="images/course4.png" alt="" /></a>
  78. </div>
  79. <div class="desc">
  80. <a href="">2018前端入门—HTML</a>
  81. <div>
  82. <span>中级</span>
  83. <span>61215次播放</span>
  84. </div>
  85. </div>
  86. </div>
  87. </section>
  88. <section class="recUpdate">
  89. <h2>最近更新</h2>
  90. <div>
  91. <div>
  92. <a href=""><img src="images/update1.png" alt="" /></a>
  93. </div>
  94. <div class="desc">
  95. <a href="">PHP快速操控Excel</a>
  96. <div>
  97. <span>老的PHPExcel已经停止更新了!目前最新的是使用phpOffi</span>
  98. </div>
  99. <div>
  100. <span>初级</span>
  101. <span>61215次播放</span>
  102. </div>
  103. </div>
  104. </div>
  105. <div>
  106. <div>
  107. <a href=""><img src="images/update2.png" alt="" /></a>
  108. </div>
  109. <div class="desc">
  110. <a href="">Thinkphp6.0正式版视频教程</a>
  111. <div>
  112. <span>Thinkphp6.0从2019年10月24日正式发布,相对测试版,有很</span>
  113. </div>
  114. <div>
  115. <span>中级</span>
  116. <span>61215次播放</span>
  117. </div>
  118. </div>
  119. </div>
  120. <div>
  121. <div>
  122. <a href=""><img src="images/update3.png" alt="" /></a>
  123. </div>
  124. <div class="desc">
  125. <a href="">2019python自觉视频</a>
  126. <div>
  127. <span>本课程主要适合从0开始学习python</span>
  128. </div>
  129. <div>
  130. <span>初级</span>
  131. <span>61215次播放</span>
  132. </div>
  133. </div>
  134. </div>
  135. <div>
  136. <div>
  137. <a href=""><img src="images/update4.png" alt="" /></a>
  138. </div>
  139. <div class="desc">
  140. <a href="">PHP开发免费公益直播课</a>
  141. <div>
  142. <span>主讲老师:朱老师</span>
  143. </div>
  144. <div>
  145. <span>初级</span>
  146. <span>61215次播放</span>
  147. </div>
  148. </div>
  149. </div>
  150. <div>
  151. <div>
  152. <a href=""><img src="images/update5.png" alt="" /></a>
  153. </div>
  154. <div class="desc">
  155. <a href="">从零开始到WEB响应式布局</a>
  156. <div>
  157. <span>重点介绍HTML,CSS,web布局</span>
  158. </div>
  159. <div>
  160. <span>中级</span>
  161. <span>61215次播放</span>
  162. </div>
  163. </div>
  164. </div>
  165. <div>
  166. <div>
  167. <a href=""><img src="images/update6.png" alt="" /></a>
  168. </div>
  169. <div class="desc">
  170. <a href="">PHP文件基本操作</a>
  171. <div>
  172. <span>文件的基本操作</span>
  173. </div>
  174. <div>
  175. <span>初级</span>
  176. <span>61215次播放</span>
  177. </div>
  178. </div>
  179. </div>
  180. </section>
  181. <section class="newArticle">
  182. <h2>最新文章</h2>
  183. <div class="desc">
  184. <div>
  185. <a href=""><span>微信引用功能什么意思</span></a>
  186. <a href=""><span>发布时间:2020-04-10</span></a>
  187. </div>
  188. <div>
  189. <a href=""><img src="images/article1.png" alt="" /></a>
  190. </div>
  191. </div>
  192. <div class="desc">
  193. <div>
  194. <a href=""><span>笔记本电脑响怎么解决</span></a>
  195. <a href=""><span>发布时间:2020-04-10</span></a>
  196. </div>
  197. <div>
  198. <a href=""><img src="images/article2.png" alt="" /></a>
  199. </div>
  200. </div>
  201. <div class="desc">
  202. <div>
  203. <a href=""><span>win7如果调整为最佳性能模式</span></a>
  204. <a href=""><span>发布时间:2020-04-10</span></a>
  205. </div>
  206. <div>
  207. <a href=""><img src="images/article3.png" alt="" /></a>
  208. </div>
  209. </div>
  210. <div class="desc">
  211. <div>
  212. <a href=""><span>关于java强引用和弱引用的介绍</span></a>
  213. <a href=""><span>发布时间:2020-04-10</span></a>
  214. </div>
  215. <div>
  216. <a href=""><img src="images/article4.png" alt="" /></a>
  217. </div>
  218. </div>
  219. <div class="desc">
  220. <div>
  221. <a href=""><span>win10无法打开wlan怎么解决</span></a>
  222. <a href=""><span>发布时间:2020-04-10</span></a>
  223. </div>
  224. <div>
  225. <a href=""><img src="images/article5.png" alt="" /></a>
  226. </div>
  227. </div>
  228. <div class="desc">
  229. <div>
  230. <a href=""><span>更多内容</span></a>
  231. </div>
  232. </div>
  233. </section>
  234. <section class="newBlog">
  235. <h2>最新博文</h2>
  236. <div class="desc">
  237. <a href="">跟小黑学漏洞利用开发之windows篇</a>
  238. <a href="">2020-04-10</a>
  239. </div>
  240. <div class="desc">
  241. <a href="">最新的xss bypass代码</a>
  242. <a href="">2020-04-10</a>
  243. </div>
  244. <div class="desc">
  245. <a href="">composer windows安装详解</a>
  246. <a href="">2020-04-10</a>
  247. </div>
  248. <div class="desc">
  249. <a href="">AI智能机器人源码</a>
  250. <a href="">2020-04-10</a>
  251. </div>
  252. <div class="desc">
  253. <a href="">利用css过虑实现网页夜模式</a>
  254. <a href="">2020-04-10</a>
  255. </div>
  256. <div class="desc">
  257. <a href="">更多内容</a>
  258. </div>
  259. </section>
  260. <section class="newAskQue">
  261. <h2>最新问答</h2>
  262. <div class="desc">
  263. <a href="">我访问不了</a>
  264. <a href="">2020-04-10</a>
  265. </div>
  266. <div class="desc">
  267. <a href="">请教一个问题,我想用cut函数</a>
  268. <a href="">2020-04-10</a>
  269. </div>
  270. <div class="desc">
  271. <a href="">验证码输入正确了怎么还提示密码错误</a>
  272. <a href="">2020-04-10</a>
  273. </div>
  274. <div class="desc">
  275. <a href="">手机没有下载SDK</a>
  276. <a href="">2020-04-10</a>
  277. </div>
  278. <div class="desc">
  279. <a href="">访问主页后,创建数据库出现错误1064</a>
  280. <a href="">2020-04-10</a>
  281. </div>
  282. <div class="desc">
  283. <a href="">更多内容</a>
  284. </div>
  285. </section>
  286. </main>
  287. <!-- 页脚部分 -->
  288. <footer>
  289. <a href="" class="iconfont"><span></span><span>首页</span></a>
  290. <a href="" class="iconfont"><span></span><span>视频</span></a>
  291. <a href="" class="iconfont"><span></span><span>社区</span></a>
  292. <a href="" class="iconfont"><span></span><span>我的</span></a>
  293. </footer>
  294. </body>
  295. </html>

css示例代码

  1. @import url(fontIcon.css);
  2. /* 公共样式 */
  3. * {
  4. padding: 0px;
  5. margin: 0px;
  6. }
  7. html {
  8. font-size: 14px;
  9. background-color: #efefef;
  10. }
  11. body {
  12. display: flex;
  13. flex-flow: column nowrap;
  14. justify-content: space-between;
  15. width: 100vw;
  16. height: 100vh;
  17. min-width: 320px;
  18. }
  19. /* 页眉样式 */
  20. header {
  21. display: flex;
  22. background-color: #2d353c;
  23. align-items: center;
  24. justify-content: space-between;
  25. /* position: relative; */
  26. padding: 0px 15px;
  27. height: 35px;
  28. /* top: 0px; */
  29. }
  30. header a {
  31. margin: 0px 10px;
  32. text-decoration: none;
  33. color: white;
  34. }
  35. header a:hover {
  36. color: greenyellow;
  37. }
  38. /* 主体结构样式 */
  39. main {
  40. flex: 1;
  41. overflow-y: scroll;
  42. display: flex;
  43. flex-flow: column nowrap;
  44. }
  45. main > a > img {
  46. width: 100vw;
  47. }
  48. /* 主体结构中的导航栏样式 */
  49. main > nav {
  50. display: flex;
  51. flex-flow: row wrap;
  52. align-items: center;
  53. justify-content: space-around;
  54. background-color: white;
  55. margin-bottom: 10px;
  56. }
  57. main > nav > div {
  58. flex: 0 1 25vw;
  59. display: flex;
  60. flex-flow: column nowrap;
  61. align-items: center;
  62. padding: 10px 0px;
  63. box-sizing: border-box;
  64. }
  65. main > nav > div > img {
  66. flex: 0 1 auto;
  67. }
  68. main > nav > div > a {
  69. flex: 0 1 auto;
  70. text-decoration: none;
  71. font-weight: bold;
  72. color: #938888;
  73. }
  74. main > nav > div > a:hover {
  75. color: coral;
  76. }
  77. /* 页面内容区样式 */
  78. main > section {
  79. display: flex;
  80. flex-flow: column nowrap;
  81. align-items: center;
  82. }
  83. main > section > h2 {
  84. color: #888888;
  85. margin-left: 10px;
  86. margin-bottom: 10px;
  87. font-size: 4.6vw;
  88. align-self: flex-start;
  89. }
  90. /* 推荐课程样式 */
  91. /* 推荐课程只有图片的样式 */
  92. .recomCourse > div:first-of-type {
  93. /* padding: 10px 10px;
  94. box-sizing: border-box; */
  95. width: 95vw;
  96. display: flex;
  97. flex-flow: row nowrap;
  98. align-items: center;
  99. justify-content: space-around;
  100. }
  101. .recomCourse > div:first-of-type > div {
  102. width: 100%;
  103. height: 100%;
  104. }
  105. .recomCourse > div:first-of-type > div > a > img {
  106. max-width: 100%;
  107. max-height: 100%;
  108. }
  109. /* 推荐课程图片+文字描述样式 */
  110. .recomCourse > div:not(:first-of-type) {
  111. padding: 10px 10px;
  112. box-sizing: border-box;
  113. width: 95vw;
  114. background-color: white;
  115. display: flex;
  116. flex-flow: row nowrap;
  117. align-items: center;
  118. justify-content: flex-start;
  119. margin-bottom: 10px;
  120. }
  121. .recomCourse > div:not(:first-of-type) > div > a > img {
  122. max-width: 100%;
  123. max-height: 100%;
  124. }
  125. /* 推荐课程图片左边的描述文字样式 */
  126. .recomCourse > div:not(:first-of-type) > .desc {
  127. flex: 0 1 auto;
  128. height: 100px;
  129. display: flex;
  130. flex-flow: column nowrap;
  131. justify-content: space-around;
  132. margin: 0px 10px;
  133. }
  134. .recomCourse > div:not(:first-of-type) > .desc > a {
  135. text-decoration: none;
  136. color: #888888;
  137. font-size: 3.6vw;
  138. }
  139. .recomCourse > div:not(:first-of-type) > .desc > a:hover {
  140. color: coral;
  141. }
  142. .recomCourse > div:not(:first-of-type) > .desc > div {
  143. font-size: 2.7vw;
  144. color: #888888;
  145. display: flex;
  146. justify-content: space-around;
  147. }
  148. .recomCourse > div:not(:first-of-type) > .desc > div > span:first-of-type {
  149. color: white;
  150. background-color: #737373;
  151. border-radius: 5px;
  152. }
  153. /* 最近更新样式 */
  154. .recUpdate > div {
  155. padding: 10px 10px;
  156. box-sizing: border-box;
  157. width: 95vw;
  158. background-color: white;
  159. display: flex;
  160. flex-flow: row nowrap;
  161. align-items: center;
  162. justify-content: space-around;
  163. margin-bottom: 10px;
  164. }
  165. .recUpdate > div > div {
  166. width: 100%;
  167. height: 100%;
  168. }
  169. .recUpdate > div > div > a > img {
  170. max-width: 100%;
  171. max-height: 100%;
  172. }
  173. /* 最近更新图片左边的描述文字样式 */
  174. .recUpdate > div > .desc {
  175. height: 100px;
  176. display: flex;
  177. flex-flow: column nowrap;
  178. justify-content: space-around;
  179. margin: 0px 10px;
  180. }
  181. .recUpdate > div > .desc {
  182. width: 100%;
  183. height: 100%;
  184. }
  185. .recUpdate > div > .desc > a {
  186. text-decoration: none;
  187. color: #888888;
  188. font-size: 3.6vw;
  189. }
  190. .recUpdate > div > .desc > a:hover {
  191. color: coral;
  192. }
  193. .recUpdate > div > .desc > div {
  194. font-size: 2.7vw;
  195. color: #888888;
  196. display: flex;
  197. justify-content: space-between;
  198. }
  199. .recUpdate > div > .desc > div:last-of-type > span:first-of-type {
  200. color: white;
  201. background-color: #737373;
  202. border-radius: 5px;
  203. }
  204. /* 最新文章样式 */
  205. .newArticle > div {
  206. padding: 10px 10px;
  207. box-sizing: border-box;
  208. width: 95vw;
  209. background-color: white;
  210. display: flex;
  211. flex-flow: row nowrap;
  212. align-items: center;
  213. justify-content: space-between;
  214. margin-bottom: 10px;
  215. }
  216. .newArticle > div > div {
  217. display: flex;
  218. flex-flow: column nowrap;
  219. justify-content: space-between;
  220. margin-left: 10px;
  221. }
  222. .newArticle > div > div > a {
  223. flex: 0 1 auto;
  224. margin-top: 10px;
  225. text-decoration: none;
  226. color: #888888;
  227. font-size: 3.6vw;
  228. font-weight: bolder;
  229. }
  230. .newArticle > div > div {
  231. width: 100%;
  232. height: 100%;
  233. }
  234. .newArticle > div > div > a > img {
  235. max-width: 100%;
  236. max-height: 100%;
  237. }
  238. .newArticle > div > div > a:hover {
  239. color: coral;
  240. }
  241. .newArticle > div > div > a:last-of-type {
  242. font-size: 2.7vw;
  243. font-weight: normal;
  244. }
  245. /* 最新文章中最后一个“更多内容”的样式 */
  246. .newArticle > div:last-of-type {
  247. display: flex;
  248. justify-content: center;
  249. align-items: center;
  250. height: 30px;
  251. }
  252. .newArticle > div:last-of-type > div > a {
  253. text-decoration: none;
  254. margin-top: 0px;
  255. color: #888888;
  256. font-size: 3.6vw;
  257. font-weight: bolder;
  258. }
  259. .newArticle > div:last-of-type > div > a:hover {
  260. color: coral;
  261. }
  262. /* 最新博文样式 */
  263. .newBlog > div {
  264. padding: 10px 10px;
  265. box-sizing: border-box;
  266. width: 95vw;
  267. background-color: white;
  268. display: flex;
  269. flex-flow: row nowrap;
  270. align-items: center;
  271. justify-content: space-between;
  272. margin-bottom: 10px;
  273. }
  274. .newBlog > div:last-of-type {
  275. justify-content: center;
  276. }
  277. .newBlog > div > a {
  278. text-decoration: none;
  279. margin-top: 0px;
  280. color: #888888;
  281. font-size: 3.6vw;
  282. font-weight: bolder;
  283. }
  284. .newBlog > div > a:last-of-type {
  285. font-weight: normal;
  286. }
  287. .newBlog > div:last-of-type > a {
  288. font-weight: bolder;
  289. }
  290. .newBlog > div > a:hover {
  291. color: coral;
  292. }
  293. /* 最新问答样式 */
  294. .newAskQue > div {
  295. padding: 10px 10px;
  296. box-sizing: border-box;
  297. width: 95vw;
  298. background-color: white;
  299. display: flex;
  300. flex-flow: row nowrap;
  301. align-items: center;
  302. justify-content: space-between;
  303. margin-bottom: 10px;
  304. }
  305. .newAskQue > div:last-of-type {
  306. justify-content: center;
  307. }
  308. .newAskQue > div > a {
  309. text-decoration: none;
  310. margin-top: 0px;
  311. color: #888888;
  312. font-size: 3.6vw;
  313. font-weight: bolder;
  314. }
  315. .newAskQue > div > a:last-of-type {
  316. font-weight: normal;
  317. }
  318. .newAskQue > div:last-of-type > a {
  319. font-weight: bolder;
  320. }
  321. .newAskQue > div > a:hover {
  322. color: coral;
  323. }
  324. /* 页脚样式 */
  325. footer {
  326. display: flex;
  327. align-items: center;
  328. justify-content: space-around;
  329. background-color: #eeeeee;
  330. height: 35px;
  331. /* position: relative; */
  332. /* bottom: 0px; */
  333. }
  334. footer > a {
  335. text-decoration: none;
  336. color: #737373;
  337. }
  338. footer > a > span {
  339. font-size: 3.6vw;
  340. }
  341. footer > a:hover {
  342. color: coral;
  343. }
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议