ASCII码 ASCII码

仿写PHP中文网首页

发布于:2022-03-30 12:32:18  栏目:技术文档

1、效果

2、HTML代码

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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. <!-- 页面初始化css -->
  8. <link rel="stylesheet" href="static/css/reset.css" />
  9. <!-- 字体图标库 -->
  10. <link
  11. rel="stylesheet"
  12. href="//at.alicdn.com/t/font_3269118_mgnsjoz5gtp.css"
  13. />
  14. <!-- 头部样式 -->
  15. <link rel="stylesheet" href="static/css/header.css" />
  16. <link rel="stylesheet" href="static/css/main.css" />
  17. <link
  18. rel="stylesheet"
  19. href="//at.alicdn.com/t/font_3288147_wz5ppbosode.css"
  20. />
  21. <title>仿PHP中文网首页</title>
  22. </head>
  23. <body>
  24. <!-- 页眉 -->
  25. <header>
  26. <!-- 顶部 -->
  27. <div class="top">
  28. <div class="content">
  29. <div class="title">PHP中文网-程序员梦开始的地方!</div>
  30. <div class="right">
  31. <a href="" class="iconfont icon-tixing"></a>
  32. <a href=""><img src="static/images/user-pic.jpeg" /></a>
  33. </div>
  34. </div>
  35. </div>
  36. <!-- 导航 -->
  37. <div class="navs">
  38. <div class="content">
  39. <a href="" class="logo"><img src="static/images/logo.png" /></a>
  40. <nav>
  41. <a href="" class="active">首页</a>
  42. <a href="">视频教程</a>
  43. <a href="">学习路径</a>
  44. <a href="">php培训</a>
  45. <a href="">资源下载</a>
  46. <a href="">技术文章</a>
  47. <a href="">社区</a>
  48. <a href="">APP下载</a>
  49. <a href="">...</a>
  50. </nav>
  51. <div class="search">
  52. <input type="search" placeholder="输入关键词搜索" />
  53. <span class="iconfont icon-fangdajing fdj"></span>
  54. </div>
  55. </div>
  56. </div>
  57. </header>
  58. <!-- 主体 -->
  59. <main>
  60. <div class="navs">
  61. <!-- 2行3列 -->
  62. <div class="left">
  63. <a href="">php开发</a>
  64. <a href="">大前端</a>
  65. <a href="">后端开发</a>
  66. <a href="">数据库</a>
  67. <a href="">移动端</a>
  68. <a href="">运维开发</a>
  69. <a href="">UI设计</a>
  70. <a href="">计算机基础</a>
  71. </div>
  72. <div class="slider">
  73. <a href="">
  74. <img src="static/images/slider.jpeg" alt="" />
  75. </a>
  76. </div>
  77. <div class="right">
  78. <div class="right-top">
  79. <!-- 我的学习 -->
  80. <a href=""><img src="static/images/user-pic.jpeg" /></a>
  81. <div class="user">
  82. <a href="">为梦兼程</a>
  83. <br />
  84. <dd>P豆&nbsp80.5</dd>
  85. </div>
  86. <a href="" class="study">我的学习</a>
  87. </div>
  88. <div class="right-news">
  89. <div class="f1">
  90. <span>问答社区</span>
  91. <a href="">答疑</a>
  92. </div>
  93. <div class="f2">
  94. <p>
  95. <span>头条</span>
  96. <a href="">中文编程出现了</a>
  97. <!-- <marquee direction="up" style="float: right;">UP</marquee> -->
  98. </p>
  99. <p>
  100. <span>新课</span>
  101. <a href="">3.9号公益直播课</a>
  102. </p>
  103. <p>
  104. <span>新班</span>
  105. <a href="">19期PHP直播班</a>
  106. </p>
  107. <p>
  108. <span>招募</span>
  109. <a href="">课程合作计划</a>
  110. </p>
  111. <p>
  112. <span>公告</span>
  113. <a href="">APP上线啦</a>
  114. </p>
  115. </div>
  116. </div>
  117. </div>
  118. <div class="bottom-left">
  119. <!-- 学习路径 -->
  120. <div class="desc">
  121. <div class="title">学习路径</div>
  122. <span>全部7个&gt</span>
  123. </div>
  124. <ul class="detail">
  125. <li onclick="">
  126. <img src="static/images/dgjj.png" alt="" />
  127. <a href="">独孤九剑</a>
  128. <span>九门课程</span>
  129. </li>
  130. <li onclick="">
  131. <img src="static/images//ynxj.png" alt="" />
  132. <a href="">独孤九贱</a>
  133. <span>9门课程</span>
  134. </li>
  135. <li onclick="">
  136. <img src="static/images//phpkjkf.png" alt="" />
  137. <a href="">独孤九贱</a>
  138. <span>9门课程</span>
  139. </li>
  140. <li onclick="">
  141. <img src="static/images//phpksrm.png" alt="" />
  142. <a href="">趣味闯关</a>
  143. <span>9门课程</span>
  144. </li>
  145. <li onclick="">
  146. <img src="static/images//dgjj.png" alt="" />
  147. <a href="">独孤九贱</a>
  148. <span>9门课程</span>
  149. </li>
  150. </ul>
  151. </div>
  152. <div class="bottom-right">
  153. <ul class="content">
  154. <li>
  155. <a href="">
  156. <b class="iconfont icon-weixin-copy"></b>
  157. <h2>官方公众号</h2>
  158. </a>
  159. </li>
  160. <li>
  161. <a href="">
  162. <b class="iconfont icon-QQ-circle-fill"></b>
  163. <h2>官方QQ群</h2>
  164. </a>
  165. </li>
  166. </ul>
  167. </div>
  168. </div>
  169. <div class="live-class">
  170. <div class="title">
  171. <h2>最新课程</h2>
  172. <a href="">更多&gt;</a>
  173. </div>
  174. <ul class="list">
  175. <li>
  176. <a href=""><img src="static/images/liveclass1.png" alt="" /></a>
  177. <dl>
  178. <dt>
  179. <i>初级</i
  180. ><a href="">前端基础HTML+CSS3从入门到精通(完整版)</a>
  181. </dt>
  182. <dd>
  183. <p>1359次学习</p>
  184. <a href=""><b class="iconfont icon-kongwujiaoxing"></b>收藏</a>
  185. </dd>
  186. </dl>
  187. </li>
  188. <li>
  189. <a href=""><img src="static/images/liveclass1.png" alt="" /></a>
  190. <dl>
  191. <dt>
  192. <i>初级</i
  193. ><a href="">前端基础HTML+CSS3从入门到精通(完整版)</a>
  194. </dt>
  195. <dd>
  196. <p>1359次学习</p>
  197. <a href=""><b class="iconfont icon-kongwujiaoxing"></b>收藏</a>
  198. </dd>
  199. </dl>
  200. </li>
  201. <li>
  202. <a href=""><img src="static/images/liveclass1.png" alt="" /></a>
  203. <dl>
  204. <dt>
  205. <i>初级</i
  206. ><a href="">前端基础HTML+CSS3从入门到精通(完整版)</a>
  207. </dt>
  208. <dd>
  209. <p>1359次学习</p>
  210. <a href=""><b class="iconfont icon-kongwujiaoxing"></b>收藏</a>
  211. </dd>
  212. </dl>
  213. </li>
  214. <li>
  215. <a href=""><img src="static/images/liveclass1.png" alt="" /></a>
  216. <dl>
  217. <dt>
  218. <i>初级</i
  219. ><a href="">前端基础HTML+CSS3从入门到精通(完整版)</a>
  220. </dt>
  221. <dd>
  222. <p>1359次学习</p>
  223. <a href=""><b class="iconfont icon-kongwujiaoxing"></b>收藏</a>
  224. </dd>
  225. </dl>
  226. </li>
  227. <li>
  228. <a href=""><img src="static/images/liveclass1.png" alt="" /></a>
  229. <dl>
  230. <dt>
  231. <i>初级</i
  232. ><a href="">前端基础HTML+CSS3从入门到精通(完整版)</a>
  233. </dt>
  234. <dd>
  235. <p>1359次学习</p>
  236. <a href=""><b class="iconfont icon-kongwujiaoxing"></b>收藏</a>
  237. </dd>
  238. </dl>
  239. </li>
  240. <li>
  241. <a href=""><img src="static/images/liveclass1.png" alt="" /></a>
  242. <dl>
  243. <dt>
  244. <i>初级</i
  245. ><a href="">前端基础HTML+CSS3从入门到精通(完整版)</a>
  246. </dt>
  247. <dd>
  248. <p>1359次学习</p>
  249. <a href=""><b class="iconfont icon-kongwujiaoxing"></b>收藏</a>
  250. </dd>
  251. </dl>
  252. </li>
  253. <li>
  254. <a href=""><img src="static/images/liveclass1.png" alt="" /></a>
  255. <dl>
  256. <dt>
  257. <i>初级</i
  258. ><a href="">前端基础HTML+CSS3从入门到精通(完整版)</a>
  259. </dt>
  260. <dd>
  261. <p>1359次学习</p>
  262. <a href=""><b class="iconfont icon-kongwujiaoxing"></b>收藏</a>
  263. </dd>
  264. </dl>
  265. </li>
  266. <li>
  267. <a href=""><img src="static/images/liveclass1.png" alt="" /></a>
  268. <dl>
  269. <dt>
  270. <i>初级</i
  271. ><a href="">前端基础HTML+CSS3从入门到精通(完整版)</a>
  272. </dt>
  273. <dd>
  274. <p>1359次学习</p>
  275. <a href=""><b class="iconfont icon-kongwujiaoxing"></b>收藏</a>
  276. </dd>
  277. </dl>
  278. </li>
  279. <li>
  280. <a href=""><img src="static/images/liveclass1.png" alt="" /></a>
  281. <dl>
  282. <dt>
  283. <i>初级</i
  284. ><a href="">前端基础HTML+CSS3从入门到精通(完整版)</a>
  285. </dt>
  286. <dd>
  287. <p>1359次学习</p>
  288. <a href=""><b class="iconfont icon-kongwujiaoxing"></b>收藏</a>
  289. </dd>
  290. </dl>
  291. </li>
  292. <li>
  293. <a href=""><img src="static/images/liveclass1.png" alt="" /></a>
  294. <dl>
  295. <dt>
  296. <i>初级</i
  297. ><a href="">前端基础HTML+CSS3从入门到精通(完整版)</a>
  298. </dt>
  299. <dd>
  300. <p>1359次学习</p>
  301. <a href=""><b class="iconfont icon-kongwujiaoxing"></b>收藏</a>
  302. </dd>
  303. </dl>
  304. </li>
  305. </ul>
  306. </div>
  307. </main>
  308. </body>
  309. </html>

3、CSS代码

初始化代码reset.css

  1. * {
  2. margin: 0;
  3. padding: 0;
  4. box-sizing: border-box;
  5. }
  6. a {
  7. text-decoration: none;
  8. color: #555;
  9. }
  10. body {
  11. background-color: rgb(243, 245, 247);
  12. }
  13. li {
  14. list-style: none;
  15. }

头部代码header.css

  1. header .top {
  2. width: 100vw;
  3. height: 40px;
  4. background-color: rgb(52, 52, 52);
  5. color: aliceblue;
  6. }
  7. header .top .content img {
  8. width: 50%;
  9. /* 下面属性是正圆 */
  10. border-radius: 50%;
  11. }
  12. header .top .content {
  13. width: 1200px;
  14. display: grid;
  15. /* 两列:400px 和 100px */
  16. grid-template-columns: 400px 100px;
  17. /* 限制隐式网格的高度 */
  18. grid-auto-rows: 40px;
  19. /* 两端对齐 */
  20. place-content: space-between;
  21. /* 垂直居中 水平默认*/
  22. place-items: center start;
  23. /* 挤到两边 */
  24. margin: auto;
  25. }
  26. header .top .content .right .iconfont {
  27. color: aliceblue;
  28. font-size: larger;
  29. }
  30. header .top .content .right {
  31. display: grid;
  32. /* 两列自适应 */
  33. grid-template-columns: repeat(2, 1fr);
  34. /* 垂直居中 水平默认*/
  35. place-items: center center;
  36. }
  37. /* 导航部分 */
  38. header .navs {
  39. width: 100vw;
  40. height: 90px;
  41. background-color: #fff;
  42. }
  43. header .navs .content {
  44. width: 1200px;
  45. display: grid;
  46. /* 三列:140px 1fr 200px */
  47. grid-template-columns: 140px 1fr 200px;
  48. /* 限制隐式网格的高度 */
  49. grid-auto-rows: 90px;
  50. /* 间隙10px */
  51. gap: 10px;
  52. /* 挤到两边 */
  53. margin: auto;
  54. /* 项目在单元格中垂直居中、水平靠右 */
  55. place-items: center start;
  56. }
  57. header .navs .content img {
  58. width: 100%;
  59. }
  60. /* 首页两个字样式 */
  61. header .navs .content nav a.active,
  62. header .navs .content nav a:hover {
  63. color: red;
  64. font-weight: bold;
  65. }
  66. header .navs .content .search {
  67. display: flex;
  68. }
  69. header .navs .content nav a {
  70. padding: 0 10px;
  71. }
  72. header .navs .content .search input[type="search"] {
  73. width: 200px;
  74. height: 36px;
  75. border: none;
  76. outline: none;
  77. background-color: #f7f8fa;
  78. /* 输入框圆角 */
  79. border-radius: 13%;
  80. padding-left: 10px;
  81. }
  82. header .navs .content .search .fdj {
  83. font-size: 22px;
  84. color: #ccc;
  85. position: relative;
  86. left: -40px;
  87. top: 7px;
  88. }

中间部分main.css

  1. main {
  2. font-size: 14px;
  3. }
  4. main .navs {
  5. /* 2行3列 */
  6. display: grid;
  7. /* 3列 */
  8. grid-template-columns: 160px 810px 190px;
  9. /* 2行 */
  10. grid-template-rows: 400px 80px;
  11. /* 列间距 */
  12. gap: 20px;
  13. /* 内容水平和垂直全部居中 */
  14. place-content: center;
  15. margin: 30px;
  16. }
  17. main .navs > * {
  18. background-color: #fff;
  19. border-radius: 20px;
  20. }
  21. /* 底部左侧前两列合并 */
  22. main .navs .bottom-left {
  23. grid-column: span 2;
  24. }
  25. main .navs .slider img {
  26. width: 100%;
  27. border-radius: 20px;
  28. }
  29. main .navs .left {
  30. display: grid;
  31. place-items: center;
  32. padding: 20px 0px;
  33. }
  34. main .navs .left a {
  35. border-radius: 20px;
  36. padding: 10px 20px;
  37. }
  38. main .navs .left a:hover {
  39. color: red;
  40. background-color: rgb(250, 223, 227);
  41. }
  42. /* 学习路径 */
  43. main .navs .bottom-left {
  44. display: grid;
  45. grid-template-columns: 100px 1fr;
  46. }
  47. main .navs .bottom-left .desc {
  48. display: grid;
  49. place-content: center;
  50. padding: 16px 0px;
  51. }
  52. main .navs .bottom-left .detail img {
  53. width: 100%;
  54. grid-row: span 2;
  55. }
  56. main .navs .bottom-left .detail {
  57. /* flex横排 */
  58. display: flex;
  59. place-items: center;
  60. place-content: space-between;
  61. margin: 0px 15px;
  62. }
  63. main .navs .bottom-left .detail li {
  64. display: grid;
  65. grid-template-columns: 36px 85px;
  66. gap: 0px 10px;
  67. place-items: center start;
  68. }
  69. main .navs .bottom-left .detail li a {
  70. font-size: 14px;
  71. }
  72. main .navs .bottom-left .detail li a:hover {
  73. font-size: 14px;
  74. color: red;
  75. }
  76. main .navs .bottom-left .detail li span {
  77. font-size: 12px;
  78. color: #999;
  79. }
  80. /* 右侧我的学习 */
  81. main .navs .right {
  82. display: grid;
  83. grid-template-rows: 142px 1fr;
  84. gap: 10px;
  85. }
  86. main .navs .right .right-top img {
  87. width: 60%;
  88. border-radius: 50%;
  89. margin-left: 20px;
  90. margin-top: 20px;
  91. }
  92. main .navs .right .right-top {
  93. display: grid;
  94. grid-template-rows: repeat(2, 1fr);
  95. grid-template-columns: repeat(2, 1fr);
  96. place-content: center;
  97. place-items: center;
  98. background-color: #fff;
  99. border-radius: 10px;
  100. }
  101. /* 会员信息靠左垂直居中 */
  102. main .navs .right .right-top .user {
  103. place-self: center start;
  104. padding: 10px 0;
  105. }
  106. main .navs .right .right-top .user a {
  107. font-size: large;
  108. font-weight: bold;
  109. }
  110. main .navs .right .right-top .user a:hover {
  111. color: red;
  112. }
  113. main .navs .right .right-top dd {
  114. font-size: 14px;
  115. color: #d0d0df;
  116. margin: 5px;
  117. }
  118. main .navs .right .right-top .study {
  119. grid-column: span 2;
  120. background-color: red;
  121. color: #fff;
  122. width: 150px;
  123. height: 34px;
  124. border-radius: 20px;
  125. padding: 3px 0;
  126. text-align: center;
  127. font-size: large;
  128. font-weight: bold;
  129. }
  130. main .navs .right .right-news {
  131. display: grid;
  132. grid-template-rows: 50px 1fr;
  133. margin: 3px 20px;
  134. }
  135. main .navs .right .right-news f1 {
  136. place-self: center start;
  137. }
  138. main .navs .right .right-news f1 span {
  139. margin-left: 5px;
  140. font-size: large;
  141. }
  142. main .navs .right .right-news .f1 a {
  143. width: 31px;
  144. height: 16px;
  145. background-color: red;
  146. color: #fff;
  147. border-radius: 2px;
  148. font-size: 12px;
  149. line-height: 16px;
  150. padding: 1px 3px;
  151. }
  152. main .navs .right .right-news .f2 {
  153. display: grid;
  154. place-items: center start;
  155. }
  156. main .navs .right .right-news .f2 a {
  157. color: #999;
  158. }
  159. main .navs .right .right-news .f2 a:hover {
  160. color: red;
  161. }
  162. /* 公众号部分 */
  163. main .navs .bottom-right .content {
  164. display: grid;
  165. grid-template-columns: repeat(2, 1fr);
  166. place-items: center;
  167. place-content: space-between;
  168. }
  169. main .navs .bottom-right .content li {
  170. width: 70px;
  171. height: 59px;
  172. text-align: center;
  173. place-content: center;
  174. place-items: center;
  175. margin: 10px 0;
  176. }
  177. main .navs .bottom-right .content li a b {
  178. font-size: 30px;
  179. place-content: center;
  180. }
  181. main .navs .bottom-right .content li a h2 {
  182. font-size: 14px;
  183. font-weight: bold;
  184. height: 16px;
  185. line-height: 16px;
  186. place-content: center;
  187. }
  188. main .navs .bottom-right .content li a h2:hover {
  189. color: red;
  190. }
  191. /* 直播课 */
  192. main .live-class {
  193. width: 1200px;
  194. margin: 30px 0;
  195. margin: auto;
  196. display: grid;
  197. grid-template-rows: 32px 530px;
  198. }
  199. main .live-class .title {
  200. display: grid;
  201. grid-template-columns: 88px 78px;
  202. grid-template-rows: 32px;
  203. place-content: space-between;
  204. place-items: center start;
  205. }
  206. main .live-class .title a {
  207. padding: 10px 10px;
  208. width: 78px;
  209. height: 32px;
  210. background: #f0f1f4;
  211. color: #999999;
  212. border-radius: 20px;
  213. text-align: center;
  214. }
  215. /* 课程列表 */
  216. main .live-class .list {
  217. display: grid;
  218. grid-template-columns: repeat(5, 1fr);
  219. grid-template-rows: repeat(2, 1fr);
  220. place-content: space-between;
  221. gap: 10px;
  222. margin-top: 30px;
  223. }
  224. main .live-class .list li {
  225. display: grid;
  226. background-color: #fff;
  227. border-radius: 5px;
  228. }
  229. main .live-class .list li img {
  230. width: 100%;
  231. border-radius: 6px 6px 0px 0px;
  232. }
  233. main .live-class .list li dl dt {
  234. margin-left: 10px;
  235. }
  236. main .live-class .list li dl dt i {
  237. float: left;
  238. width: 28px;
  239. height: 16px;
  240. background: #93999f;
  241. line-height: 16px;
  242. overflow: hidden;
  243. text-align: center;
  244. font-style: normal;
  245. font-size: 11px;
  246. color: #ffffff;
  247. margin-right: 10px;
  248. margin-top: 3px;
  249. }
  250. main .live-class .list li dl dd {
  251. display: flex;
  252. margin-top: 15px;
  253. margin-left: 15px;
  254. place-content: space-between;
  255. color: #b7b7b7;
  256. }
  257. main .live-class .list li dl dd a {
  258. color: #b7b7b7;
  259. margin-right: 15px;
  260. }
相关推荐
阅读 +