博客列表 >仿php中文网首页页面(一部分实战)演示

仿php中文网首页页面(一部分实战)演示

想做一个躺平的程序员
想做一个躺平的程序员原创
2022年03月27日 16:28:13487浏览

页面效果

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. <title>Document</title>
  7. <link rel="stylesheet" href="css/reset.css">
  8. <link rel="stylesheet" href="css/header.css">
  9. <link rel="stylesheet" href="css/nav.css">
  10. <link rel="stylesheet" href="//at.alicdn.com/t/font_3279262_g4m9xqg0me8.css">
  11. <link rel="stylesheet" href="css/main.css">
  12. <link rel="stylesheet" href="css/footer.css">
  13. </head>
  14. <body>
  15. <!-- 页面头部 -->
  16. <header>
  17. <div class="content">
  18. <div class="title">
  19. php中文网-程序员梦开始的地方!
  20. </div>
  21. <div class="right">
  22. <span class="iconfont icon-lingsheng "></span>
  23. <img src="images/user-pic.jpeg" alt="">
  24. </div>
  25. </div>
  26. </header>
  27. <!-- 页面导航 -->
  28. <nav>
  29. <div class="content">
  30. <a href=""> <img src="images/logo.png" alt=""></a>
  31. <div class="kernel">
  32. <a href="#">首页<span class="iconfont icon-xiangxia"></span></a>
  33. <a href="">视频教程<span class="iconfont icon-xiangxia"></span></a>
  34. <a href="">学习路径<span class="iconfont icon-xiangxia"></span></a>
  35. <a href="">php培训<span class="iconfont icon-xiangxia"></span></a>
  36. <a href="">资源下载<span class="iconfont icon-xiangxia" ></span></a>
  37. <a href="">技术文章<span class="iconfont icon-xiangxia" ></span></a>
  38. <a href="">社区<span class="iconfont icon-xiangxia"></span></a>
  39. <a href="">app下载 <span class="iconfont icon-shouji"></span></a>
  40. </div>
  41. <div class="search">
  42. <input type="search" placeholder="请输入关键字">
  43. <span class="iconfont icon-41"></span>
  44. </div>
  45. </div>
  46. </nav>
  47. <!-- 页面主体 -->
  48. <main>
  49. <div class="main">
  50. <!-- 左边主体 -->
  51. <div class="left">
  52. <a href="#">php开发&nbsp;<span class="iconfont icon-youjiantou"></span></a>
  53. <a href="">大前端&nbsp;<span class="iconfont icon-youjiantou"></span></a>
  54. <a href="">后端开发&nbsp;<span class="iconfont icon-youjiantou"></span></a>
  55. <a href="">数据库&nbsp;<span class="iconfont icon-youjiantou"></span></a>
  56. <a href="">移动端&nbsp;<span class="iconfont icon-youjiantou"></span></a>
  57. <a href="">运维开发&nbsp;<span class="iconfont icon-youjiantou"></span></a>
  58. <a href="">UI设计&nbsp;<span class="iconfont icon-youjiantou"></span></a>
  59. <a href="">计算机基础&nbsp;<span class="iconfont icon-youjiantou"></span></a>
  60. </div>
  61. <!-- 中心主体 -->
  62. <div class="content">
  63. <img src="images/slider.jpeg" alt="">
  64. </div>
  65. <!-- 右边头部主体 -->
  66. <div class="right">
  67. <div class="top">
  68. <img src="images/user-pic.jpeg" alt="">
  69. <div class="top-name">
  70. <span>想做一个躺平的程序员</span>
  71. <p>p豆: <a href="">18</a> </p>
  72. </div>
  73. <a href="">我的学习</a>
  74. </div>
  75. <!-- 右边尾部主题 -->
  76. <div class="botton">
  77. <div class="doubt">问答社区 &nbsp<a href="">疑问</a> </div>
  78. <div class="give">
  79. <a href="">头条:
  80. <span>“程序员做饭指南”,GitHub热榜第一!</span>
  81. </a>
  82. <a href="">新课: <span>3.9号公益直播课</span></a>
  83. <a href="">新班:<span>19期PHP直播班</span></a>
  84. <a href="">招募:<span>课程合作计划</span></a>
  85. <a href="">公告:<span>APP上线啦</span> </a>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </main>
  91. <!-- 主体尾部 -->
  92. <div class="main-footer">
  93. <div class="learning">
  94. <a class="learning-path">
  95. <span>学习路径</span>
  96. <p>全部7部 <span class="iconfont icon-youjiantou"></span></p>
  97. </a>
  98. </div>
  99. <!-- 主题尾部内容 -->
  100. <div class="learning-content">
  101. <a href="">
  102. <img src="images/dgjj.png" alt="">
  103. <dl>
  104. <dt>独孤九剑</dt>
  105. <dd>九门课程</dd>
  106. </dl>
  107. </a>
  108. <a href="">
  109. <img src="images/ynxj.png" alt="">
  110. <dl>
  111. <dt>玉女心经</dt>
  112. <dd>七门课程</dd>
  113. </dl>
  114. </a>
  115. <a href="">
  116. <img src="images/tlbb.png" alt="">
  117. <dl>
  118. <dt>天龙八部</dt>
  119. <dd>三门课程</dd>
  120. </dl>
  121. </a>
  122. <a href="">
  123. <img src="images/phpksrm.png" alt="">
  124. <dl>
  125. <dt>自学指南</dt>
  126. <dd>19门课程</dd>
  127. </dl>
  128. </a>
  129. <a href="">
  130. <img src="images/phpkjkf.png" alt="">
  131. <dl>
  132. <dt>趣味闯关</dt>
  133. <dd>22门课程</dd>
  134. </dl>
  135. </a>
  136. </div>
  137. <!-- 主题尾部右边 -->
  138. <div class="learning-right">
  139. <a href="">
  140. <span class="iconfont icon-gongzhonghao1"></span>
  141. <p>微信公众号</p>
  142. </a>
  143. <a href="">
  144. <span class="iconfont icon-weixingongzhonghao"></span>
  145. <p>QQ公众号</p>
  146. </a>
  147. </div>
  148. </div>
  149. <!-- 页面尾部 -->
  150. <footer>
  151. <!-- 尾部标题 -->
  152. <div class="top">
  153. <p>最新课程</p>
  154. <a href="">更多</a>
  155. </div>
  156. <!-- 尾部内容 -->
  157. <div class="content">
  158. <div class="item">
  159. <a href="">
  160. <img src="https://img.php.cn/upload/course/000/000/068/623d6ce036b81626.jpg" alt="">
  161. <dl>
  162. <dt>
  163. <span>初级</span>
  164. <dd>javaScript基础语法[domlbomles6新语</dd>
  165. </dt>
  166. </dl>
  167. <div>
  168. <span>学习105次</span>
  169. <span class="iconfont icon-shoucang" > 收藏</span>
  170. </div>
  171. </a>
  172. </div>
  173. <div class="item">
  174. <a href="">
  175. <img src="https://img.php.cn/upload/course/000/000/068/62398b673ecc4667.jpg" alt="">
  176. <dl>
  177. <dt>
  178. <span>初级</span>
  179. <dd>前端最全HTTP基础原理及应用</dd>
  180. </dt>
  181. </dl>
  182. <div>
  183. <span>学习105次</span>
  184. <span class="iconfont icon-shoucang" > 收藏</span>
  185. </div>
  186. </a>
  187. </div>
  188. <div class="item">
  189. <a href="">
  190. <img src="https://img.php.cn/upload/course/000/000/068/62398b5dadc79937.jpg" alt="">
  191. <dl>
  192. <dt>
  193. <span>初级</span>
  194. <dd>HTTP协议</dd>
  195. </dt>
  196. </dl>
  197. <div>
  198. <span>学习105次</span>
  199. <span class="iconfont icon-shoucang" > 收藏</span>
  200. </div>
  201. </a>
  202. </div>
  203. <div class="item">
  204. <a href="">
  205. <img src="https://img.php.cn/upload/course/000/000/068/62381b3e817d4409.jpg" alt="">
  206. <dl>
  207. <dt>
  208. <span>中级</span>
  209. <dd>API接口开发规范【服务器标准的接口Restful API开发</dd>
  210. </dt>
  211. </dl>
  212. <div>
  213. <span>学习22</span>
  214. <span class="iconfont icon-shoucang" > 收藏</span>
  215. </div>
  216. </a>
  217. </div>
  218. <div class="item">
  219. <a href="">
  220. <img src="https://img.php.cn/upload/course/000/000/068/623057031def7707.jpg" alt="">
  221. <dl>
  222. <dt>
  223. <span>高级</span>
  224. <dd>Mysql查询优化方案【大厂架构师亲授】</dd>
  225. </dt>
  226. </dl>
  227. <div>
  228. <span>学习55次</span>
  229. <span class="iconfont icon-shoucang">收藏</span>
  230. </div>
  231. </a>
  232. </div>
  233. <div class="item">
  234. <a href="">
  235. <img src="https://img.php.cn/upload/course/000/000/068/622efba5b8f59620.jpg" alt="">
  236. <dl>
  237. <dt>
  238. <span>初级</span>
  239. <dd>Wen前端Promise教程</dd>
  240. </dt>
  241. </dl>
  242. <div>
  243. <span>学习44次</span>
  244. <span class="iconfont icon-shoucang">收藏</span>
  245. </div>
  246. </a>
  247. </div>
  248. <div class="item">
  249. <a href="">
  250. <img src="https://img.php.cn/upload/course/000/000/068/622ee24c8180c270.jpg" alt="">
  251. <dl>
  252. <dt>
  253. <span>初级</span>
  254. <dd>Bootstrap框架讲解</dd>
  255. </dt>
  256. </dl>
  257. <div>
  258. <span>学习10次</span>
  259. <span class="iconfont icon-shoucang"> 收藏</span>
  260. </div>
  261. </a>
  262. </div>
  263. <div class="item">
  264. <a href="">
  265. <img src="https://img.php.cn/upload/course/000/000/068/6226fe0150292919.jpg" alt="">
  266. <dl>
  267. <dt>
  268. <span>初级</span>
  269. <dd>javaScript基础语法[domlbomles6新语</dd>
  270. </dt>
  271. </dl>
  272. <div>
  273. <span>学习12次</span>
  274. <span class=" iconfont icon-shoucang" > 收藏</span>
  275. </div>
  276. </a>
  277. </div>
  278. </div>
  279. </footer>
  280. </body>
  281. </html>

css代码

初始化

  1. `*` {
  2. /*初始化 */
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: content-box;
  6. }
  7. a{
  8. /* 取消a链接下划线 */
  9. text-decoration: none;
  10. }
  11. body{
  12. /* 给页面主体添加背景颜色 */
  13. background-color: rgb(243, 245, 247);
  14. }

css头部代码

  1. header{
  2. /* 宽度为 100% 高度为40px 背景颜色为知道你自定义 */
  3. width: 100%;
  4. height: 40px;
  5. background-color: rgb(52, 52, 52)
  6. ;
  7. }
  8. header .content{
  9. /* 宽度为1200px 高度为40px 自动居中 */
  10. width: 1200px;
  11. height: 40px;
  12. margin: 0 auto;
  13. display: grid;
  14. grid-template-columns: 240px 1fr;
  15. place-items: center;
  16. }
  17. header .content .title{
  18. /* 字体加粗 字体颜色为浅灰色 字体样式为自定义 */
  19. font-weight: bold;
  20. font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
  21. color: silver;
  22. }
  23. header .content .right{
  24. /* 设置为弹性容器 ,定义项目在主轴的对齐方式 */
  25. display: flex;
  26. justify-content:end;
  27. }
  28. header .content .right span{
  29. /* 添加字体颜色 设置内边距 */
  30. color: azure;
  31. padding: 10px 10px;
  32. }
  33. header .content .right img{
  34. /* 定义图片的宽度和高度,边框半径 内边距 */
  35. width: 3%;
  36. height: 3%;
  37. border-radius: 10em;
  38. padding: 5px 10px;
  39. }

css导航代码

  1. nav{
  2. /* //定义自定义的宽度和高度 背景颜色为白色 */
  3. width: 100%;
  4. height: 90px;
  5. background-color:rgb(255, 255, 255)
  6. ;
  7. }
  8. nav .content{
  9. /* 定义宽度1200px 高度为90px 外边距为居中
  10. 设置为网格容器 1行3列 */
  11. width: 1200px;
  12. height: 90px;
  13. margin: auto;
  14. display: grid;
  15. grid-template-columns: 140px 1fr 190px;
  16. }
  17. nav .content img{
  18. padding: 1em 1em 1em 0;
  19. width: 100%;
  20. }
  21. nav .content .kernel{
  22. /* 设置为弹性容器 子项目在主轴的对齐方式为两端对齐 */
  23. padding: 1em;
  24. display: flex;
  25. justify-content: space-between;
  26. /* 子项目在交叉轴的对齐方式为居中 */
  27. place-items: center;
  28. }
  29. nav .content .kernel a{
  30. /* 字体加粗 字体大小位20px 字体位黑体 */
  31. color: black;
  32. font-size: 20px;
  33. font-weight: bold;
  34. }
  35. nav .content .kernel a:hover{
  36. /* 设置鼠标移到指定的元素,字体颜色改变为自定义的,字体加大 */
  37. color: brown;
  38. font-size: 25px;
  39. }
  40. nav .content .kernel a:first-of-type{
  41. /* first-of-type:第一个
  42. 设置第一个a链接的颜色为红色 */
  43. color: brown;
  44. }
  45. nav .content .search{
  46. /* 设置为弹性容器 项目在交叉轴的对齐方式为居中 */
  47. display: flex;
  48. align-items: center;
  49. }
  50. nav .content .search input{
  51. /* 去掉轮廓 边框为none 边框半径为20px
  52. 背景颜色为 自定义 */
  53. outline: none;
  54. border: none;
  55. border-radius: 20px;
  56. height: 40px;
  57. width: 200px;
  58. background-color: rgb(247, 248, 250);
  59. }
  60. nav .content .search .icon-41{
  61. /* 定位为相等定位,向左移动-30px */
  62. position: relative;
  63. left: -30px;
  64. }

css主题(main)代码

  1. main .main{
  2. /*设置宽度为1200px 高度为400px
  3. 自动居中 外边距头部为10px
  4. 设置为网格容器,1行3列 */
  5. width: 1200px;
  6. height: 400px;
  7. margin: auto;
  8. margin-top: 10px;
  9. display: grid;
  10. /* 定义网格容器的列数 */
  11. grid-template-columns: 160px 1fr 190px;
  12. }
  13. main .main .left{
  14. /* 高度为400px 背景颜色为白色
  15. 边框半径为 1em 内边距头部距离为10px
  16. 设置为网格容器 水平对齐方式为居中 垂直对齐方式为居中 */
  17. height: 400px;
  18. background-color: white;
  19. border-radius: 1em;
  20. padding-top: 10px;
  21. display: grid;
  22. place-items: center center;
  23. }
  24. main .main .left a{
  25. /* 字体大小为18px 字体颜色为黑体 字体加粗 */
  26. font-size: 18px;
  27. color: black;
  28. font-weight: bold;
  29. }
  30. main .main .left a:hover{
  31. /* 鼠标移到 a链接上 背景改变为自定义 */
  32. padding: 1px;
  33. background-color:rgba(212, 34, 34, 0.8);
  34. }
  35. main .main .content{
  36. padding: 0 10px;
  37. }
  38. main .main .content img{
  39. /* 图片的边框半径为1em 字体加粗 */
  40. border-radius: 1em;
  41. font-weight: bold;
  42. }
  43. main .main .right{
  44. /* 设置为网格容器 2行1列 边框半径为10px */
  45. display: grid;
  46. grid-template-rows: 140px 260px;
  47. border-radius: 10px;
  48. }
  49. main .main .right .top{
  50. /* 设置为网格容器 定义 2行2列 垂直对齐方式为stretch
  51. 背景颜色为 白色 */
  52. display: grid;
  53. margin-top: 10px;
  54. grid-template-columns: 50px 1fr;
  55. grid-template-rows: 80px 1fr;
  56. align-items: stretch;
  57. background-color: white;
  58. }
  59. main .main .right .top img{
  60. width: 100%;
  61. border-radius: 100%;
  62. }
  63. main .main .right .top .top-name{
  64. /* 设置为 网格容器 2行1列 */
  65. display: grid;
  66. grid-template-rows: 1fr 1fr;
  67. }
  68. main .main .right .top span{
  69. /* 字体大小为20px 字体样式为自定义 字体加粗
  70. 超出的内容会以省略号显示 */
  71. font-size: 20px;
  72. font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
  73. font-weight: bold;
  74. /*下面三个属性实现 文本内容超出一定范围内会以省略号显示*/
  75. white-space:nowrap;
  76. overflow : hidden;
  77. text-overflow: ellipsis;
  78. }
  79. main .main .right .top .top-name p,
  80. main .main .right .top .top-name p a{
  81. color: silver;
  82. }
  83. main .main .right .top> a{
  84. /* 外边距为自动填充
  85. 子项目跨越3列
  86. 子项目在垂直方向的对齐方式为居中
  87. 轮廓为none
  88. 字体颜色为白色
  89. 背景颜色为红色 */
  90. margin: auto;
  91. grid-column: span 3;
  92. place-items: center;
  93. outline: none;
  94. border-radius: 5px;
  95. color: white;
  96. padding: 10px;
  97. background-color:red;
  98. }
  99. main .main .right .botton{
  100. margin-top: 10px;
  101. background-color: white;
  102. border-radius: 10px;
  103. }
  104. main .main .right .botton .doubt{
  105. /* 设置为弹性容器 字体大小为20px */
  106. font-size: 20px;
  107. display: flex;
  108. }
  109. main .main .right .botton .doubt a{
  110. background-color: red;
  111. color: white;
  112. }
  113. main .main .right .botton .give{
  114. /* 设置为网格容器 定义为5行1列 */
  115. display: grid;
  116. grid-template-rows: 1fr 1fr 1fr 1fr 1fr;
  117. }
  118. main .main .right .botton .give a{
  119. padding:1px;
  120. font-size: 18px;
  121. color: black;
  122. }
  123. main .main .right .botton .give a span{
  124. /* 定义文本超出一定范围内会以省略号显示
  125. 字体大小为10px
  126. 字体颜色为浅灰色
  127. */
  128. white-space: nowrap;
  129. overflow: hidden;
  130. text-overflow: ellipsis;
  131. font-size: 10px;
  132. color: silver;
  133. }
  134. .main-footer{
  135. /* 宽度为1200px 高度为80px 外边距填充为居中
  136. 背景颜色为 白色
  137. 设置为网格容器 1行3列 */
  138. width: 1200px;
  139. height: 80px;
  140. margin: auto;
  141. margin-top: 20px;
  142. border-radius: 1px;
  143. background-color:white;
  144. display: grid;
  145. grid-template-columns: 190px 1fr 290px;
  146. }
  147. .main-footer .learning .learning-path{
  148. /* 设置为弹性容器 主轴为垂直 */
  149. display: flex;
  150. flex-direction: column;
  151. padding: 20px 0 0 10px;
  152. }
  153. .main-footer .learning .learning-path span{
  154. font-weight: bold;
  155. font-size: 17px;
  156. }
  157. .main-footer .learning .learning-path p{
  158. color: silver;
  159. }
  160. .main-footer .learning .learning-path p>span{
  161. font-size: 10px;
  162. }
  163. .main-footer .learning-content{
  164. /* 设置为网格容器 1行 列 */
  165. display: grid;
  166. grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  167. }
  168. .main-footer .learning-content a{
  169. /* 设置为弹性容器 默认主轴为水平 项目在交叉轴的对齐方式为居中 */
  170. display: flex;
  171. align-items: center;
  172. }
  173. .main-footer .learning-content img{
  174. width: 30%;
  175. height: 50%;
  176. }
  177. .main-footer .learning-content dt{
  178. font-weight: bold;
  179. color: black;
  180. }
  181. .main-footer .learning-content dd{
  182. font-size: 14px;
  183. font-weight: bold;
  184. color: silver;
  185. }
  186. .main-footer .learning-right{
  187. /* 设置为网格容器 1行2列 子项目在垂直方向的对齐方式为居中 */
  188. display: grid;
  189. grid-template-columns: 1fr 1fr;
  190. place-items: center;
  191. }
  192. .main-footer .learning-right a{
  193. font-size: 20px;
  194. font-weight: bold;
  195. }

css尾部代码

  1. footer{
  2. margin-top: 20px;
  3. }
  4. footer .top{
  5. /* 宽度为1200px 高度为40px
  6. 外边距填充为居中
  7. 设置为弹性容器 默认主轴为水平
  8. 主轴对齐方式为两端对齐
  9. 交叉轴对齐方式为 底部向上 */
  10. width: 1200px;
  11. height: 40px;
  12. margin: auto;
  13. display: flex;
  14. justify-content: space-between;
  15. align-items: flex-end;
  16. }
  17. footer .top p {
  18. font-size: 25px;
  19. font-weight: bold;
  20. }
  21. footer .top a{
  22. color: silver;
  23. font-size: 15px;
  24. }
  25. footer .content{
  26. /* 宽度为1200px 高度为530px
  27. 设置为网格容器 2行4列
  28. 外边距填充为居中
  29. 外边距头部为10xp
  30. 边框半径为1px */
  31. width: 1200px;
  32. height: 530px;
  33. display: grid;
  34. grid-template-columns: 1fr 1fr 1fr 1fr;
  35. grid-template-rows: 265px 265px;
  36. margin: auto;
  37. margin-top: 10px;
  38. border-radius: 1px;
  39. }
  40. footer .content .item{
  41. /* 外边距为5px
  42. 设置为网格容器 3行 1列
  43. 背景颜色为白色 */
  44. margin-top: 5px;
  45. display: grid;
  46. grid-template-rows: 1fr 1fr 1fr;
  47. margin: 5px 5px;
  48. background-color: white;
  49. }
  50. footer .content .item a{
  51. border-radius: 10px;
  52. }
  53. footer .content .item img{
  54. width: 100%;
  55. }
  56. footer .content .item dl dd {
  57. /* 字体大小为18px
  58. 字体加粗
  59. 字体颜色为黑体
  60. 高度为48px
  61. 内边距左边为10px
  62. 内边距头部为5px */
  63. font-size: 18px;
  64. font-weight: bold;
  65. padding-top: 5px;
  66. height: 48px;
  67. padding-left: 10px;
  68. color: black;
  69. }
  70. footer .content .item dl dt{
  71. font-size: 16px;
  72. color:silver;
  73. padding-left: 10px;
  74. }
  75. footer .content .item div{
  76. /* 外边距为 上下位0 左右位10px
  77. 字体大小位 15px
  78. 设置为 弹性容器 默认为主轴为水平
  79. 主轴的对齐方式为两端对齐
  80. 交叉轴的对齐方式为居中
  81. 字体颜色为 浅灰色 */
  82. margin: 0 10px;
  83. font-size: 15px;
  84. display: flex;
  85. justify-content:space-between;
  86. align-items: center;
  87. color: silver;
  88. }

用到的图标

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