Blogger Information
Blog 29
fans 1
comment 0
visits 14973
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
仿PHP中文网的一小部分
Pharaoh
Original
282 people have browsed it

效果图

代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>PHP.CN</title>
  8. <link rel="stylesheet" href="css/header.css" />
  9. <link rel="stylesheet" href="css/icon-font.css" />
  10. </head>
  11. <body>
  12. <header>
  13. <div>
  14. <div class="top">
  15. <p>php中文网-程序员梦开始的地方</p>
  16. <div class="right">
  17. <a href="" class="iconfont icon-tixingtianchong"></a>
  18. <a href=""><img src="user_avatar.jpg" alt="" /></a>
  19. </div>
  20. </div>
  21. </div>
  22. <main>
  23. <div class="nav">
  24. <a href=""><img src="logo-2x.png" alt="" /></a>
  25. <ul>
  26. <li><a href="">首页</a></li>
  27. <li><a href="">视频教程</a></li>
  28. <li><a href="">学习路径</a></li>
  29. <li><a href="">PHP培训</a></li>
  30. <li><a href="">资源下载</a></li>
  31. <li><a href="">技术文章</a></li>
  32. <li><a href="">社区</a></li>
  33. </ul>
  34. <div class="sreach">
  35. <input type="sreach" placeholder="输入关键词搜索" />
  36. <span class="iconfont icon-fangdajing1"></span>
  37. </div>
  38. </div>
  39. </main>
  40. </header>
  41. <main>
  42. <div class="top">
  43. <div class="left">
  44. <ul>
  45. <li><a href="">php开发</a></li>
  46. <li><a href="">大前端</a></li>
  47. <li><a href="">后端开发</a></li>
  48. <li><a href="">数据库</a></li>
  49. <li><a href="">移动端</a></li>
  50. <li><a href="">运维开发</a></li>
  51. <li><a href="">UI设计</a></li>
  52. <li><a href="">计算机基础</a></li>
  53. </ul>
  54. </div>
  55. <div class="middle">
  56. <img src="main.png" alt="" />
  57. </div>
  58. <div class="right">
  59. <div class="top">
  60. <div>
  61. <div class="img"><img src="user_avatar.jpg" alt="" /></div>
  62. <div class="user">
  63. <h2>Pharaoh</h2>
  64. <span>P豆 9999</span>
  65. </div>
  66. </div>
  67. <div><a href="">我要学习</a></div>
  68. </div>
  69. <div class="buttom">
  70. <div>
  71. <span>问答社区</span>
  72. <span>答疑</span>
  73. </div>
  74. <div>
  75. <span>头条</span>
  76. <span>66个面试问题</span>
  77. </div>
  78. <div>
  79. <span>福利</span>
  80. <span>限时折扣>></span>
  81. </div>
  82. <div>
  83. <span>新班</span>
  84. <span>20期PHP线上班</span>
  85. </div>
  86. <div>
  87. <span>招募</span>
  88. <span>课程合作计划</span>
  89. </div>
  90. <div>
  91. <span>公告</span>
  92. <span>APP上线啦</span>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <div class="buttom">
  98. <div class="left"></div>
  99. <div class="right"></div>
  100. </div>
  101. </main>
  102. <div class="two">
  103. <div class="left">
  104. <div>
  105. <h2>学习路径</h2>
  106. <p>全部7个</p>
  107. </div>
  108. <div>
  109. <div><img src="dgjj.png" alt="" /></div>
  110. <div>
  111. <a href="">独孤九剑</a>
  112. <p>9门课程</p>
  113. </div>
  114. </div>
  115. <div>
  116. <div><img src="ynxj.png" alt="" /></div>
  117. <div>
  118. <a href="">玉女心经</a>
  119. <p>5门课程</p>
  120. </div>
  121. </div>
  122. <div>
  123. <div><img src="tlbb.png" alt="" /></div>
  124. <div>
  125. <a href="">天龙八部</a>
  126. <p>3门课程</p>
  127. </div>
  128. </div>
  129. <div>
  130. <div><img src="phpkjkf.png" alt="" /></div>
  131. <div>
  132. <a href="">自学指南</a>
  133. <p>19门课程</p>
  134. </div>
  135. </div>
  136. <div>
  137. <div><img src="phpksrm.png" alt="" /></div>
  138. <div>
  139. <a href="">趣味闯关</a>
  140. <p>22门课程</p>
  141. </div>
  142. </div>
  143. </div>
  144. <div class="right">
  145. <div>
  146. <div><img src="../默写/dy.png" alt="" /></div>
  147. <div>官方工众号</div>
  148. </div>
  149. <div>
  150. <div><img src="../默写/dy.png" alt="" /></div>
  151. <div>官方QQ群</div>
  152. </div>
  153. </div>
  154. </div>
  155. </body>
  156. </html>

CSS代码

  1. @import url(reset.css);
  2. body {
  3. background-color: rgb(212, 212, 212);
  4. }
  5. header > div:first-child {
  6. background-color: rgb(61, 60, 60);
  7. width: 100vw;
  8. }
  9. header .top {
  10. width: 1200px;
  11. height: 50px;
  12. margin: auto;
  13. display: grid;
  14. grid-template-columns: 400px 100px;
  15. grid-auto-rows: 50px;
  16. place-content: center space-between;
  17. place-items: center start;
  18. }
  19. header .top p {
  20. color: rgb(235, 235, 235);
  21. }
  22. header div:first-child .right {
  23. display: grid;
  24. grid-template-columns: 50px 30px;
  25. place-items: center;
  26. }
  27. header div:first-child .right a:first-child {
  28. color: white;
  29. }
  30. header div:first-child .top .right a img {
  31. width: 100%;
  32. border-radius: 20px;
  33. }
  34. body header main {
  35. width: 100vw;
  36. background-color: white;
  37. box-shadow: 0px 6px 8px rgb(7, 17, 27, 0.1);
  38. }
  39. .nav {
  40. width: 1200px;
  41. height: 80px;
  42. display: flex;
  43. margin: auto;
  44. justify-content: space-between;
  45. align-items: center;
  46. }
  47. header main .nav ul {
  48. width: 800px;
  49. display: flex;
  50. }
  51. header main .nav ul li {
  52. margin-left: 15px;
  53. }
  54. header main .nav ul li a:hover,
  55. header main .nav ul li:first-child a {
  56. color: red;
  57. }
  58. header main .nav a:first-child img {
  59. width: 150px;
  60. }
  61. header main .nav div input {
  62. border-radius: 20px;
  63. height: 35px;
  64. background-color: rgb(211, 211, 211);
  65. border: none;
  66. outline: none;
  67. padding-left: 9px;
  68. }
  69. body header main .nav .sreach span {
  70. position: relative;
  71. left: -30px;
  72. }
  73. body > main {
  74. width: 1200px;
  75. margin: 30px auto;
  76. }
  77. body > main > .top {
  78. display: grid;
  79. grid-template-columns: 160px 810px 190px;
  80. gap: 10px;
  81. font-size: 14px;
  82. }
  83. body > main > .top > * {
  84. background-color: white;
  85. border-radius: 25px;
  86. }
  87. body main .top .left ul {
  88. display: grid;
  89. grid-template-rows: repeat(8, 1fr);
  90. place-content: center;
  91. place-items: center;
  92. padding-top: 10px;
  93. }
  94. body main .top .left ul li {
  95. padding: 15px 25px;
  96. border-radius: 25px;
  97. }
  98. body main .top .left ul li:hover {
  99. background-color: crimson;
  100. }
  101. body main .top .middle img {
  102. border-radius: 25px;
  103. }
  104. body main .top .right {
  105. display: grid;
  106. grid-template-rows: 140px 240px;
  107. place-content: center;
  108. place-items: center;
  109. }
  110. body main .right .top > div:first-child {
  111. width: 100%;
  112. display: flex;
  113. justify-content: flex-start;
  114. }
  115. body > main .right .top > div:first-child .img {
  116. width: 40px;
  117. }
  118. body main .right .top > div:first-child img {
  119. width: 100%;
  120. border-radius: 50px;
  121. }
  122. body > main .right .top {
  123. height: 100%;
  124. width: 100%;
  125. padding: 10px 25px;
  126. border-bottom: 1px solid rgb(212, 212, 212);
  127. overflow: hidden;
  128. }
  129. body > main .right .top > div:first-child .user h2 {
  130. font-size: 0.9rem;
  131. }
  132. body > main .right .top > div:first-child .user span {
  133. font-size: 0.6rem;
  134. color: rgb(141, 141, 141);
  135. }
  136. body > main .right .top > div:first-child .user {
  137. padding: 0 10px;
  138. }
  139. body > main .right .top > div:last-child {
  140. width: 150px;
  141. height: 34px;
  142. margin: auto;
  143. background-color: #f11717;
  144. text-align: center;
  145. border-radius: 20px;
  146. margin-top: 30px;
  147. }
  148. body > main .right .top > div:last-child a {
  149. display: block;
  150. line-height: 34px;
  151. color: white;
  152. }
  153. body > main .right .buttom {
  154. padding: 0 20px;
  155. margin-top: 30px;
  156. display: grid;
  157. grid-template-rows: repeat(6, 40px);
  158. place-items: auto center;
  159. place-content: space-between center;
  160. }
  161. body > main .right .buttom div span:last-child {
  162. color: rgb(180, 180, 180);
  163. }
  164. body > main .right .buttom div:first-child span:last-child {
  165. display: inline-block;
  166. background-color: orangered;
  167. color: white;
  168. border-radius: 5px;
  169. width: 35px;
  170. text-align: center;
  171. }
  172. body .two {
  173. width: 1200px;
  174. height: 80px;
  175. display: grid;
  176. grid-template-columns: 980px 190px;
  177. margin: auto;
  178. }
  179. body .two .left {
  180. display: flex;
  181. background-color: white;
  182. justify-content: center;
  183. align-items: center;
  184. border-radius: 15px;
  185. }
  186. body .two > .left > div:first-child {
  187. width: 79px;
  188. }
  189. body .two > .left > div:not(div:first-child) {
  190. display: flex;
  191. }
  192. body .two > .left > div:not(div:first-child) > div {
  193. width: 130px;
  194. height: 40px;
  195. }
  196. body .two > .left > div:not(div:first-child) > div:first-child {
  197. width: 40px;
  198. height: 40px;
  199. padding: 0 5px;
  200. font-size: 20px;
  201. }
  202. body .two > .left > div:not(div:first-child) > div > p {
  203. color: darkgrey;
  204. font-size: 0.5rem;
  205. }
  206. body .two > .left > div:not(div:first-child) > div img {
  207. width: 90%;
  208. }
  209. body .two > .left div:first-child {
  210. font-size: 5px;
  211. margin: 0 0px;
  212. }
  213. body .two .right {
  214. margin-left: 12px;
  215. border-radius: 15px;
  216. display: flex;
  217. justify-content: center;
  218. align-items: center;
  219. background-color: white;
  220. width: 190px;
  221. }
  222. body .two .right div div:last-child {
  223. font-weight: bold;
  224. font-size: x-small;
  225. }
  226. body .two .right div img {
  227. width: 30%;
  228. border-radius: 50px;
  229. }
  230. body .two .right div {
  231. text-align: center;
  232. }

感想

其实有很多种办法实现:浮动,弹性布局,盒子布局,甚至可以互相嵌套,还需要多多练习

Correcting teacher:PHPzPHPz

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