博客列表 >php中文网布局实战

php中文网布局实战

土老帽
土老帽原创
2022年03月28日 16:48:52521浏览

仿PHP中文网页面布局

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

css代码

reset.css

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

header.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: 50%;
  9. border-radius: 50%;
  10. }
  11. header .top .content {
  12. width: 1200px;
  13. display: grid;
  14. grid-template-columns: 400px 100px;
  15. grid-auto-rows: 40px;
  16. place-content: space-between;
  17. place-items: center start;
  18. margin: auto;
  19. }
  20. header .top .content .right .iconfont {
  21. color: #eee;
  22. font-size: larger;
  23. }
  24. header .top .content .right {
  25. display: grid;
  26. grid-template-columns: repeat(2, 1fr);
  27. place-items: center;
  28. }
  29. /* 导航 */
  30. header .navs {
  31. width: 100vw;
  32. height: 90px;
  33. background-color: #fff;
  34. }
  35. header .navs .content {
  36. width: 1200px;
  37. /* border: 1px solid #000; */
  38. display: grid;
  39. grid-template-columns: 140px 1fr 200px;
  40. grid-auto-rows: 90px;
  41. gap: 10px;
  42. margin: auto;
  43. place-items: center start;
  44. }
  45. header .navs .content img {
  46. width: 100%;
  47. }
  48. header .navs .content nav a.active,
  49. header .navs .content nav a:hover {
  50. color: red;
  51. font-weight: bold;
  52. }
  53. header .navs .content .search {
  54. display: flex;
  55. }
  56. header .navs .content nav a {
  57. padding: 0 10px;
  58. }
  59. header .navs .content .search input[type="search"] {
  60. width: 200px;
  61. height: 36px;
  62. border: none;
  63. outline: none;
  64. background-color: #f7f8fa;
  65. border-radius: 20px;
  66. padding-left: 10px;
  67. }
  68. header .navs .content .search .fdj {
  69. font-size: 22px;
  70. color: #ccc;
  71. position: relative;
  72. left: -40px;
  73. top: 5px;
  74. }
  75. `

main-nav.css

  1. main {
  2. font-size: 14px;
  3. }
  4. main .navs {
  5. /* 2行3列 */
  6. display: grid;
  7. grid-template-columns: 160px 810px 190px;
  8. grid-template-rows: 400px 80px;
  9. gap: 20px;
  10. place-content: center;
  11. margin: 30px 0;
  12. }
  13. main .navs > * {
  14. background-color: #fff;
  15. border-radius: 20px;
  16. /* outline: 1px solid red; */
  17. }
  18. /* 底部左侧占2列 */
  19. main .navs .bottom-left {
  20. grid-column: span 2;
  21. }
  22. main .navs .slider img {
  23. width: 100%;
  24. border-radius: 20px;
  25. }
  26. /* 左侧导航 */
  27. main .navs .left {
  28. display: grid;
  29. place-items: center;
  30. padding: 20px 0;
  31. }
  32. main .navs .left a:hover {
  33. color: red;
  34. background-color: rgb(250, 223, 227);
  35. }
  36. main .navs .left a {
  37. border-radius: 20px;
  38. padding: 10px 20px;
  39. }
  40. /* 底部左侧 */
  41. main .navs .bottom-left {
  42. display: grid;
  43. grid-template-columns: 100px 1fr;
  44. }
  45. main .navs .bottom-left .desc {
  46. display: grid;
  47. place-items: center;
  48. padding: 16px;
  49. }
  50. main .navs .bottom-left .detail img {
  51. width: 100%;
  52. grid-row: span 2;
  53. }
  54. main .navs .bottom-left .detail {
  55. display: flex;
  56. place-items: center;
  57. place-content: space-between;
  58. }
  59. main .navs .bottom-left .detail li {
  60. display: grid;
  61. grid-template-columns: 36px 85px;
  62. gap: 0 10px;
  63. place-items: center start;
  64. }
  65. main .navs .bottom-left .detail li a {
  66. font-size: 14px;
  67. }
  68. main .navs .bottom-left .detail li a:hover {
  69. color: red;
  70. }
  71. main .navs .bottom-left .detail li span,
  72. main .navs .bottom-left .desc span {
  73. font-size: 12px;
  74. color: #999;
  75. }
  76. main .navs .bottom-right .phpXxljMenu .iconfont,
  77. main .navs .bottom-right .aBlack .iconfont {
  78. font-size: 3em;
  79. }
  80. main .navs .bottom-right {
  81. width: 190px;
  82. }
  83. main .navs .bottom-right li {
  84. float: left;
  85. width: 70px;
  86. margin-top: 13px;
  87. margin-left: 20px;
  88. display: inline-block;
  89. text-align: center;
  90. }
  91. main .navs .bottom-right li a {
  92. display: inline-block;
  93. text-align: center;
  94. }
  95. main .navs .right .phpTbxxTitle2 {
  96. width: 190px;
  97. height: 141px;
  98. border-bottom: 1px solid #eeeeee;
  99. }
  100. main .navs .right .phpTbxxCont2 {
  101. width: 155px;
  102. margin: auto;
  103. }
  104. main .navs .right .phpTbxxTitle2 img {
  105. float: left;
  106. width: 40px;
  107. height: 40px;
  108. border-radius: 100px;
  109. display: block;
  110. margin-top: 20px;
  111. }
  112. main .navs .right .phpTbxxTitle2 dl {
  113. float: right;
  114. width: 105px;
  115. margin-top: 15px;
  116. }
  117. main .navs .right .phpTbxxTitle2 dd {
  118. height: 16px;
  119. line-height: 16px;
  120. overflow: hidden;
  121. font-size: 12px;
  122. color: #999999;
  123. margin-top: 10px;
  124. }
  125. main .navs .right .phpTbxxTitle2 .phpTbxxXue {
  126. display: block;
  127. width: 150px;
  128. height: 34px;
  129. background: #f11717;
  130. border-radius: 100px;
  131. line-height: 34px;
  132. text-align: center;
  133. color: #ffffff;
  134. text-decoration: none;
  135. overflow: hidden;
  136. margin-top: 20px;
  137. margin-left: 20px;
  138. }
  139. main .navs .right .phpWenda {
  140. width: 150px;
  141. margin: auto;
  142. padding-top: 7px;
  143. }
  144. main .navs .right .phpWenda p {
  145. height: 18px;
  146. line-height: 18px;
  147. overflow: hidden;
  148. }
  149. main .navs .right .phpWenda .cont1 a {
  150. display: inline-block;
  151. width: 31px;
  152. height: 16px;
  153. background: #ff583d;
  154. border-radius: 2px;
  155. font-size: 15px;
  156. color: #ffffff;
  157. line-height: 16px;
  158. text-align: center;
  159. }
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议