博客列表 >仿php中文网首页(部分)

仿php中文网首页(部分)

上草一方
上草一方原创
2022年04月01日 23:31:57553浏览

仿php中文网首页

实现效果图如下:

HTML代码如下:

  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="static/css/reset.css">
  9. <link rel="stylesheet" href="static/css/header.css">
  10. <link rel="stylesheet" href="////at.alicdn.com/t/font_3272169_a1dyfv37nht.css">
  11. <link rel="stylesheet" href="static/css/main-nav.css">
  12. </head>
  13. <body>
  14. <!-- 页眉 -->
  15. <header>
  16. <!-- 1.顶部 -->
  17. <div class="top">
  18. <div class="content">
  19. <div class="title">php中文网程序员梦开始的地方!</div>
  20. <div class="right">
  21. <a href="" class="iconfont icon-tixingtianchong"></a>
  22. <a href=""><img src="static/images/唯美3.jpeg" alt=""></a>
  23. </div>
  24. </div>
  25. </div>
  26. <!-- 2.导航 -->
  27. <div class="navs">
  28. <div class="content">
  29. <a href="" class="logo"><img src="static/images/logo.png" alt=""></a>
  30. <nav>
  31. <a href="" class="active">首页</a>
  32. <a href="">视频教程</a>
  33. <a href="">学习路径</a>
  34. <a href="">php培训</a>
  35. <a href="">资源下载</a>
  36. <a href="">技术文章</a>
  37. <a href="">社区</a>
  38. <a href="">APP下载</a>
  39. </nav>
  40. <div class="search">
  41. <input type="search" placeholder="输入关键字搜索">
  42. <span class="iconfont icon-fangdajing fdj"></span>
  43. </div>
  44. </div>
  45. </div>
  46. </header>
  47. <!-- 主体 -->
  48. <main>
  49. <div class="navs">
  50. <!-- 做个2行3列 -->
  51. <div class="left">
  52. <a href="">php开发</a>
  53. <a href="">大前端</a>
  54. <a href="">后端开发</a>
  55. <a href="">数据库/a>
  56. <a href="">移动端</a>
  57. <a href="">运维开发</a>
  58. <a href="">UI设计</a>
  59. <a href="">计算机基础</a>
  60. </div>
  61. <div class="slider">
  62. <a href="">
  63. <img src="static/images/slider.jpeg" alt="">
  64. </a>
  65. </div>
  66. <div class="right">
  67. <div class="right1">
  68. <img src="static/images/唯美3.jpeg" alt="">
  69. <div class="right1-1"><a href="">上草一方</a><br>
  70. <span>P豆:20豆</span></div>
  71. </div>
  72. <div class="right2"><a href="">我&nbsp;的&nbsp;学&nbsp;习</a></div>
  73. <div class="right3">
  74. <span>问答社区</span>&nbsp;&nbsp;
  75. <a href="">答&nbsp;疑</a>
  76. </div>
  77. <table class="right4">
  78. <tr>
  79. <td><span>头条</span>&nbsp;&nbsp;
  80. <input type="text"></td>
  81. </tr>
  82. <tr>
  83. <td><span>新课</span>&nbsp;&nbsp;
  84. <a href="">x月x日公益直播课</a></td>
  85. </tr>
  86. <tr>
  87. <td><span>新班</span>&nbsp;&nbsp;
  88. <a href="">19期PHP直播班</a></td>
  89. </tr>
  90. <tr>
  91. <td><span>招募</span>&nbsp;&nbsp;
  92. <a href="">课程合作</a></td>
  93. </tr>
  94. <tr>
  95. <td><span>公告</span>&nbsp;&nbsp;
  96. <a href="">APP上线啦</a></td>
  97. </tr>
  98. </table>
  99. </div>
  100. <!-- 底部左边的 -->
  101. <div class="bottom-left">
  102. <!-- 学习路径 -->
  103. <div class="desc">
  104. <div class="title">学习路径</div>
  105. <span>全部七个&gt;</span>
  106. </div>
  107. <ul class="detail">
  108. <li onclick="">
  109. <img src="static/images/dgjj.png" alt="">
  110. <div><a href="">独孤九贱</a><br>
  111. <span>9门课程</span></div>
  112. </li>
  113. <li onclick="">
  114. <img src="static/images/ynxj.png" alt="">
  115. <div><a href="">玉女心经</a><br>
  116. <span>5门课程</span></div>
  117. </li>
  118. <li onclick="">
  119. <img src="static/images/tlbb.png" alt="">
  120. <div><a href="">天龙八部</a><br>
  121. <span>3门课程</span></div>
  122. </li>
  123. <li onclick="">
  124. <img src="static/images/phpkjkf.png" alt="">
  125. <div><a href="">自学指南</a><br>
  126. <span>19门课程</span></div>
  127. </li>
  128. <li onclick="">
  129. <img src="static/images/phpksrm.png" alt="">
  130. <div><a href="">趣味闯关</a><br>
  131. <span>22门课程</span></div>
  132. </li>
  133. </ul>
  134. </div>
  135. <!-- 底部右边的 -->
  136. <div class="bottom-right">
  137. <table>
  138. <tr height="40">
  139. <td width="100" align="center"><span class="iconfont icon-weixin wx"></span></td>
  140. <td width="100" align="center"><span class="iconfont icon-qq qq1"></span></td>
  141. </tr>
  142. <tr>
  143. <td align="center"><a href="">官方公众号</a></td>
  144. <td align="center"><a href="">官方QQ群</a></td>
  145. </tr>
  146. </table>
  147. </div>
  148. </div>
  149. </main>
  150. </body>
  151. </html>

头部CSS代码如下:

  1. header .top {
  2. width: 100vw;
  3. height: 40px;
  4. background-color: rgb(52, 52, 52);
  5. color: #aaa;
  6. }
  7. header .top .content img{
  8. width: 60%;
  9. border-radius: 50%;
  10. }
  11. header .top .content{
  12. width: 1200px;
  13. display: grid;
  14. /* 将它分成两列 */
  15. grid-template-columns: 400px 100px;
  16. /* 两端对齐 */
  17. place-content: space-between;
  18. /* 下面不能用place-content:center,因为没有剩余空间 */
  19. margin: auto;
  20. /* 让文本垂直居中 */
  21. place-items: center start;
  22. /* 手工设置隐式网格行高 */
  23. grid-auto-rows: 40px;
  24. /* 这两行代码实现的效果一样,有什么区别? */
  25. /* grid-template-rows: 40px; */
  26. }
  27. header .top .right .iconfont{
  28. color: #eee;
  29. font-size: large;
  30. }
  31. header .top .content .right{
  32. display: grid;
  33. /* 下面这行代码是两列,每一列自适应 */
  34. grid-template-columns: repeat(2,1fr);
  35. place-items: center;
  36. }
  37. /* 导航 */
  38. header .navs{
  39. width: 100%;
  40. height: 90px;
  41. background-color: #fff;
  42. }
  43. header .navs .content{
  44. width: 1200px;
  45. /* border: 1px solid #000; */
  46. display: grid;
  47. grid-template-columns: 140px 1fr 200px;
  48. margin: auto;
  49. grid-auto-rows: 90px;
  50. /* 列与列之间的间隙 */
  51. gap: 10px;
  52. place-items: center start;
  53. }
  54. header .navs .content img{
  55. width: 100%;
  56. border-radius: 50%;
  57. }
  58. header .navs .content nav a.active,
  59. header .navs .content nav a:hover{
  60. color: red;
  61. font-weight: bold;
  62. }
  63. header .navs .content .search{
  64. display: flex;
  65. }
  66. header .navs .content nav a{
  67. /* 让每个a标签之间有一些间隙,左右间隙 */
  68. padding: 0 15px;
  69. }
  70. /* 下面这一块代码似乎没有效果 */
  71. header .navs .content .search input[type='search']{
  72. width: 200px;
  73. height: 36px;
  74. border: none;
  75. outline: none;
  76. background-color: #f7f8fa;
  77. border-radius: 20%;
  78. display: flex;
  79. }
  80. /* 给放大镜做一个定位 */
  81. header .navs .content .search .fdj {
  82. font-size: 22px;
  83. color: #ccc;
  84. position: relative;
  85. left: -40px;
  86. top: 5px;
  87. }

主体部分css代码如下:

  1. main {
  2. font-size: 14px;
  3. }
  4. main .navs{
  5. display: grid;
  6. /* 分成三列,各自列宽如下 */
  7. grid-template-columns: 160px 810px 190px;
  8. /* 分成两行,各自行宽如下 */
  9. grid-template-rows: 400px 80px;
  10. /* 间隙 */
  11. gap: 20px;
  12. place-content: center;
  13. margin: 30px 0;
  14. }
  15. main .navs>* {
  16. background-color: #fff;
  17. border-radius: 4%;
  18. outline: 1px solid red;
  19. }
  20. /* 底部左侧占两列 */
  21. main .navs .bottom-left{
  22. grid-column: span 2;
  23. }
  24. main .navs .slider img{
  25. width: 100%;
  26. border-radius: 4%;
  27. }
  28. /* 左侧导航 */
  29. main .navs .left{
  30. display: grid;
  31. place-items: center;
  32. padding: 20px 0;
  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-items: center;
  50. }
  51. main .navs .bottom-left .detail img{
  52. width: 100%;
  53. /* 图片跨行操作,跨两行 */
  54. /* grid-row: sapn 2; */
  55. }
  56. main .navs .bottom-left .detail{
  57. display: flex;
  58. place-items: center;
  59. place-content: space-between;
  60. }
  61. main .navs .bottom-left .detail li{
  62. display: grid;
  63. grid-template-columns: 36px 85px;
  64. gap: 0 10px;
  65. place-items: center start;
  66. }
  67. main .navs .bottom-left .detail li a {
  68. font-size: 14px;
  69. }
  70. main .navs .bottom-left .detail li a:hover {
  71. color: red;
  72. }
  73. main .navs .bottom-left .detail li span,
  74. main .navs .bottom-left .desc span {
  75. font-size: 12px;
  76. color: #999;
  77. }
  78. /* 右侧导航 */
  79. main .right{
  80. display: grid;
  81. }
  82. main .right .right1{
  83. height: 100px;
  84. /* border: 1px solid black; */
  85. display: grid;
  86. grid-template-columns: 60px 1fr;
  87. place-content: space-between;
  88. place-content: center;
  89. }
  90. main .right .right1 img{
  91. width: 100%;
  92. border-radius: 50%;
  93. }
  94. main .right .right1 .right1-1{
  95. margin: auto;
  96. }
  97. main .right .right2 {
  98. width: 160px;
  99. height: 40px;
  100. border-radius: 20px;
  101. background-color: red;
  102. display: grid;
  103. place-content: center;
  104. margin: auto;
  105. }
  106. main .right .right2 a{
  107. color: #fff;
  108. font-weight: bold;
  109. }
  110. main .right .right3 a{
  111. background-color: red;
  112. color: #fff;
  113. font-weight: bold;
  114. }
  115. /* 底部右边的 */
  116. main .navs .bottom-right .wx,
  117. main .navs .bottom-right .qq1{
  118. font-size: 40px;
  119. }
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议