博客列表 >php中文网仿站

php中文网仿站

magician风
magician风原创
2020年04月14日 16:31:421224浏览

先写总结:
因为时间问题只能听录播,听完觉得商城仿站完全能听懂,周一开始做中文网仿站,觉得有两个小时应该可以搞定,结果…… 四个小时都做很糟糕,还有一些细节上纠结了半天没敢深究。本来昨天可以交的,网页上测试可以,放服务器上一看,完全蒙了,手机端完全乱的,图片到处乱跑。晚上看孩子稍的又研究了一阵,发现了些问题,今天早上看了会md文档,发现之前思路就根本不清楚,看文档觉得自己茅塞顿开,又看了php中文网的源码觉得有1个小时可以重新布局css了。下午2点整到现在越整越糊涂。完全跟自己想的不一样。昨天主要css选择器搞不清,今天发现问题太多了,还是css的问题。先不深究了,赶紧看grid的视频,不然又要拉下课了,先跟上节奏第一,然后慢慢消化吧。先坐实例熟悉,然后一定要做项目,这样才能真的吃透。
先这样吧。
实例链接

网页上效果图网页上效果图

昨晚手机上效果图

现在手机效果图

截了张长图


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/header_footer.css" />
  7. <link rel="stylesheet" href="css/body.css" />
  8. <link rel="stylesheet" href="css/font_icon.css" />
  9. <title>php中文网</title>
  10. </head>
  11. <body>
  12. <!-- 公共头部 -->
  13. <header>
  14. <div class="login">
  15. <a href=""><img src="images/login.png" alt="" /></a>
  16. </div>
  17. <li class="logo">
  18. <a href=""><img src="images/logo.png" alt="" /></a>
  19. </li>
  20. <li class="menu"><i class="iconfont"></i></li>
  21. </header>
  22. <!-- 轮播图 -->
  23. <div class="slider">
  24. <a href=""><img src="images/slider.png" alt="" /></a>
  25. </div>
  26. <!-- 主导航区 -->
  27. <nav>
  28. <div>
  29. <a href=""><img src="images/html.png" alt="" /></a>
  30. <a href="">HTML/CSS</a>
  31. </div>
  32. <div>
  33. <a href=""><img src="images/JavaScript.png" alt="" /></a>
  34. <a href="">JavaScript</a>
  35. </div>
  36. <div>
  37. <a href=""><img src="images/server.png" alt="" /></a>
  38. <a href="">服务端</a>
  39. </div>
  40. <div>
  41. <a href=""><img src="images/sql.png" alt="" /></a>
  42. <a href="">数据库</a>
  43. </div>
  44. <div>
  45. <a href=""><img src="images/app.png" alt="" /></a>
  46. <a href="">移动端</a>
  47. </div>
  48. <div>
  49. <a href=""><img src="images/manual.png" alt="" /></a>
  50. <a href="">手册</a>
  51. </div>
  52. <div>
  53. <a href=""><img src="images/tool2.png" alt="" /></a>
  54. <a href="">工具</a>
  55. </div>
  56. <div>
  57. <a href=""><img src="images/live.png" alt="" /></a>
  58. <a href="">直播</a>
  59. </div>
  60. </nav>
  61. <!-- 推荐课程 -->
  62. <div class="course">
  63. <h2 class="title">推荐课程</h2>
  64. <div>
  65. <a href=""><img src="images/tjkc1.jpg" alt="" /></a>
  66. <a href=""><img src="images/tjkc2.jpg" alt="" /></a>
  67. </div>
  68. <div>
  69. <a href=""><img src="images/tjkc3.jpg" alt="" /> </a>
  70. <div>
  71. <a href=""><span>CI框架30分钟极速入门</span></a>
  72. <p><span> 中级 </span> 61302次播放</p>
  73. </div>
  74. </div>
  75. <div>
  76. <a href=""><img src="images/tjkc3.jpg" alt="" /> </a>
  77. <div>
  78. <a href=""><span>CI框架30分钟极速入门</span></a>
  79. <p><span> 中级 </span> 61302次播放</p>
  80. </div>
  81. </div>
  82. </div>
  83. <!-- 最新更新 -->
  84. <div class="update">
  85. <h2 class="title">最新更新</h2>
  86. <div>
  87. <a href=""><img src="images/zxgx1.png" alt="" /> </a>
  88. <div>
  89. <a href=""><span>PHP快速操控Exce</span></a>
  90. <p>
  91. 老的PHPExcel已经停止更新了!目前最新的是使用phpOffice插件PhpSpreadsheet,用纯
  92. php 编写的库,它提供了一组类,允许您读取和写入不同的电子表格文
  93. </p>
  94. <p><span> 中级 </span> 61302次播放</p>
  95. </div>
  96. </div>
  97. <div>
  98. <a href=""><img src="images/zxgx2.png" alt="" /> </a>
  99. <div>
  100. <a href=""><span>PHP快速操控Exce</span></a>
  101. <p>
  102. 老的PHPExcel已经停止更新了!目前最新的是使用phpOffice插件PhpSpreadsheet,用纯
  103. php 编写的库,它提供了一组类,允许您读取和写入不同的电子表格文
  104. </p>
  105. <p><span> 中级 </span> 61302次播放</p>
  106. </div>
  107. </div>
  108. <div>
  109. <a href=""><img src="images/zxgx3.jpg" alt="" /> </a>
  110. <div>
  111. <a href=""><span>PHP快速操控Exce</span></a>
  112. <p>
  113. 老的PHPExcel已经停止更新了!目前最新的是使用phpOffice插件PhpSpreadsheet,用纯
  114. php 编写的库,它提供了一组类,允许您读取和写入不同的电子表格文
  115. </p>
  116. <p><span> 中级 </span> 61302次播放</p>
  117. </div>
  118. </div>
  119. </div>
  120. <!-- 最新文章 -->
  121. <div class="text">
  122. <h2 class="title">最新文章</h2>
  123. <div>
  124. <div>
  125. <a href=""><span>word破折号怎么打出来</span></a>
  126. <p>发布时间:2020-04-13</p>
  127. </div>
  128. <a href=""><img src="images/zxwz1.jpg" alt="" /> </a>
  129. </div>
  130. <div>
  131. <div>
  132. <a href=""><span>word破折号怎么打出来</span></a>
  133. <p>发布时间:2020-04-13</p>
  134. </div>
  135. <a href=""><img src="images/zxwz2.jpg" alt="" /> </a>
  136. </div>
  137. <div>
  138. <div>
  139. <a href=""><span>word破折号怎么打出来</span></a>
  140. <p>发布时间:2020-04-13</p>
  141. </div>
  142. <a href=""><img src="images/zxwz3.jpg" alt="" /> </a>
  143. </div>
  144. <div class="more">更多内容</div>
  145. </div>
  146. <!-- 最新博文 -->
  147. <div class="text2">
  148. <h2 class="title">最新博文</h2>
  149. <div>
  150. <a href=""><span>微信的openid和unionid</span></a>
  151. <p>发布时间:2020-04-13</p>
  152. </div>
  153. <div>
  154. <a href=""><span>微信的openid和unionid</span></a>
  155. <p>发布时间:2020-04-13</p>
  156. </div>
  157. <div>
  158. <a href=""><span>微信的openid和unionid</span></a>
  159. <p>发布时间:2020-04-13</p>
  160. </div>
  161. <div class="more">更多内容</div>
  162. </div>
  163. <!-- 最新问答 -->
  164. <div class="question">
  165. <h2 class="title">最新问答</h2>
  166. <div>
  167. <a href=""><span>composer安装问题</span></a>
  168. <p>发布时间:2020-04-13</p>
  169. </div>
  170. <div>
  171. <a href=""><span>composer安装问题</span></a>
  172. <p>发布时间:2020-04-13</p>
  173. </div>
  174. <div>
  175. <a href=""><span>composer安装问题</span></a>
  176. <p>发布时间:2020-04-13</p>
  177. </div>
  178. <div class="more">更多内容</div>
  179. </div>
  180. <footer>
  181. <a href="">
  182. <span class="iconfont"></span>
  183. <span>首页</span>
  184. </a>
  185. <a href="">
  186. <span class="iconfont"></span>
  187. <span>视频</span>
  188. </a>
  189. <a href="">
  190. <span class="iconfont"></span>
  191. <span>社区</span>
  192. </a>
  193. <a href="">
  194. <span class="iconfont"></span>
  195. <span>我的</span>
  196. </a>
  197. </footer>
  198. </body>
  199. </html>

css代码

  1. * {
  2. margin: 0;
  3. padding: 0;
  4. }
  5. html {
  6. width: 100vw;
  7. height: 100vh;
  8. font-size: 14px;
  9. }
  10. a {
  11. text-decoration: none;
  12. color: grey;
  13. }
  14. body {
  15. min-width: 300px;
  16. background-color: #efefef;
  17. display: flex;
  18. flex-flow: column nowrap;
  19. }
  20. header {
  21. display: flex;
  22. height: 5vh;
  23. background-color: black;
  24. align-items: center;
  25. justify-content: space-between;
  26. padding: 0px 15px;
  27. box-sizing: border-box;
  28. position: fixed;
  29. width: 100vw;
  30. }
  31. header > .login > a img {
  32. height: 3.5vh;
  33. }
  34. header > .logo > a img {
  35. height: 5.5vh;
  36. }
  37. header > .menu {
  38. font-size: 3vh;
  39. color: white;
  40. }
  41. body > .slider {
  42. margin-top: 5vh;
  43. height: 20vh;
  44. background-color: black;
  45. }
  46. .slider > a img {
  47. width: 100%;
  48. height: 100%;
  49. }
  50. /* 主导航区 */
  51. nav {
  52. height: 28vh;
  53. display: flex;
  54. flex-flow: row wrap;
  55. align-content: center;
  56. background-color: #fff;
  57. }
  58. nav > div {
  59. width: 25vw;
  60. display: flex;
  61. flex-flow: column nowrap;
  62. text-align: center;
  63. }
  64. nav > div img {
  65. margin-top: 10px;
  66. width: 50%;
  67. }
  68. .title {
  69. font-size: 1.2rem;
  70. color: gray;
  71. /* font-weight: normal; */
  72. margin: 10px 0;
  73. }
  74. /* 主推课程 */
  75. .course {
  76. width: 95vw;
  77. height: 56vh;
  78. display: flex;
  79. flex-flow: column nowrap;
  80. margin: 0 2vw;
  81. }
  82. /* 第一行双图片样式 */
  83. .course > div:first-of-type {
  84. height: 17vh;
  85. display: flex;
  86. justify-content: space-between;
  87. align-items: center;
  88. }
  89. /* 第一行图片样式 */
  90. .course > div:first-of-type > a > img {
  91. width: 46vw;
  92. height: 100%;
  93. }
  94. /* 第二三行容器样式 */
  95. .course > div:not(:first-of-type) {
  96. height: 17vh;
  97. display: flex;
  98. justify-content: space-between;
  99. background-color: white;
  100. align-items: center;
  101. padding: 5px;
  102. box-sizing: border-box;
  103. margin-top: 5px;
  104. }
  105. /* 第二三行子容器样式 */
  106. .course > div > div {
  107. width: 60vw;
  108. height: 10vh;
  109. display: flex;
  110. flex-flow: column nowrap;
  111. align-items: flex-start;
  112. justify-content: space-around;
  113. padding: 0 5px;
  114. }
  115. /* 第二三行图片样式 */
  116. .course > div:not(:first-of-type) > a img {
  117. width: 40vw;
  118. height: 100%;
  119. }
  120. /* 文字中级的圆角黑色背景 */
  121. .course > div > div > p > span:first-of-type {
  122. width: 13vw;
  123. color: white;
  124. background-color: #1d1d1d;
  125. border-radius: 10px;
  126. }
  127. .update {
  128. width: 95vw;
  129. height: 55vh;
  130. display: flex;
  131. flex-flow: column nowrap;
  132. margin: 0 2vw;
  133. }
  134. .update > div {
  135. height: 15vh;
  136. display: flex;
  137. justify-content: space-between;
  138. background-color: white;
  139. align-items: center;
  140. padding: 10px;
  141. box-sizing: border-box;
  142. margin-top: 5px;
  143. }
  144. .update > div > div {
  145. width: 50vw;
  146. height: 10vh;
  147. display: flex;
  148. flex-flow: column nowrap;
  149. align-items: flex-start;
  150. justify-content: space-around;
  151. padding: 5px;
  152. }
  153. .update > div > a {
  154. width: 50vw;
  155. height: 10vh;
  156. display: flex;
  157. flex-flow: column nowrap;
  158. align-items: flex-start;
  159. justify-content: space-around;
  160. padding: 5px;
  161. }
  162. .update > div > a img {
  163. width: 100%;
  164. height: 100%;
  165. }
  166. .update > div > div p {
  167. display: inline-block;
  168. white-space: nowrap;
  169. width: 100%;
  170. overflow: hidden;
  171. text-overflow: ellipsis;
  172. }
  173. .update > div > div > p > span:first-of-type {
  174. width: 13vw;
  175. color: white;
  176. background-color: #1d1d1d;
  177. border-radius: 10px;
  178. }
  179. .text {
  180. width: 95vw;
  181. height: 45vh;
  182. display: flex;
  183. flex-flow: column nowrap;
  184. margin: 0 2vw;
  185. }
  186. .text > div {
  187. height: 10vh;
  188. display: flex;
  189. justify-content: space-between;
  190. background-color: white;
  191. align-items: center;
  192. padding: 5px;
  193. box-sizing: border-box;
  194. margin-top: 5px;
  195. }
  196. .text > div > div {
  197. width: 50vw;
  198. height: 10vh;
  199. display: flex;
  200. flex-flow: column nowrap;
  201. align-items: flex-start;
  202. justify-content: space-around;
  203. padding: 5px;
  204. }
  205. .text > div > a img {
  206. width: 40vw;
  207. height: 100%;
  208. }
  209. .text > .more {
  210. height: 5vh;
  211. width: 95vw;
  212. justify-content: center;
  213. text-align: center;
  214. }
  215. .text2 {
  216. width: 95vw;
  217. height: 33vh;
  218. display: flex;
  219. flex-flow: column nowrap;
  220. margin: 0 2vw;
  221. }
  222. .text2 > div {
  223. height: 6vh;
  224. display: flex;
  225. justify-content: space-around;
  226. background-color: white;
  227. align-items: center;
  228. padding: 5px;
  229. box-sizing: border-box;
  230. margin-top: 5px;
  231. }
  232. .text2 > .more {
  233. height: 4vh;
  234. width: 95vw;
  235. justify-content: center;
  236. text-align: center;
  237. }
  238. .question {
  239. width: 95vw;
  240. height: 40vh;
  241. display: flex;
  242. flex-flow: column nowrap;
  243. margin: 0 2vw;
  244. }
  245. .question > div {
  246. height: 6vh;
  247. display: flex;
  248. justify-content: space-around;
  249. background-color: white;
  250. align-items: center;
  251. padding: 5px;
  252. box-sizing: border-box;
  253. margin-top: 5px;
  254. }
  255. .question > .more {
  256. height: 4vh;
  257. width: 95vw;
  258. justify-content: center;
  259. text-align: center;
  260. }
  261. footer {
  262. display: flex;
  263. height: 8vh;
  264. color: #666;
  265. background-color: #efefef;
  266. border-top: 1px solid #ccc;
  267. align-items: center;
  268. justify-content: space-between;
  269. padding: 0 8vw;
  270. box-sizing: border-box;
  271. position: fixed;
  272. width: 100vw;
  273. bottom: 0;
  274. }
  275. footer > a {
  276. display: flex;
  277. flex-flow: column nowrap;
  278. align-items: center;
  279. }
  280. footer > a:first-of-type {
  281. color: red;
  282. }
  283. footer > a > span:first-of-type {
  284. font-size: 1.6rem;
  285. }
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议
magician风2020-04-16 14:50:451楼
这布局很乱没有什么参考意义,但是总结到几点知识,之前学了,但是用的时候没注意到,比如长度单位 px,%,vw,px固定大小,考虑到各种移动端设备大小不同,目前一般不推荐使用。我的感觉外框用vw,不过一定要设置MAX,不然大显示器就乱了,用%的时候一定要定义父容器的大小,这个是不继承的,定义祖容器没用,这次这里翻了个跟头,浪费了很多时间。图片到处乱跑。再就是css选择器,之前理解的不准确,css很多代码重复部署。脑子里框架结构思路还是不清晰,以后部署一定要先部署版块,后添加内容。写这个的时候还没学grid,后面时间允许的话,用grid重写一个。