博客列表 >使用grid网格布局仿PHP中文网首页部分

使用grid网格布局仿PHP中文网首页部分

梦想
梦想原创
2022年07月17日 18:52:25694浏览
  1. <header>
  2. <div class="headertop">
  3. <!-- 头部 -->
  4. <div class="headercenter">
  5. <!-- 头部左边 -->
  6. <div class="headerleft">
  7. <p>php中文网-程序员梦开始的地方</p>
  8. </div>
  9. <!-- 头部右边 -->
  10. <div class="haderright">
  11. <a href="" class="iconfont icon-tixingtianchong"></a>
  12. <a href="">
  13. <img src="images/user_avatar.jpg" alt="">
  14. </a>
  15. </div>
  16. </div>
  17. </div>
  18. <!-- 导航开始 -->
  19. <div class="navs">
  20. <div class="content">
  21. <a href="" class="logo"><img src="images/logo.png" alt=""></a>
  22. <nav>
  23. <a href="" class="active">首页</a>
  24. <a href="">视频教程</a>
  25. <a href="">学习路径</a>
  26. <a href="">技术博客</a>
  27. <a href="">资源下载</a>
  28. </nav>
  29. <div class="right">
  30. <input type="text" placeholder="请输入关键词">
  31. <span class="iconfont icon-fangdajing1 sousuo"></span>
  32. </div>
  33. </div>
  34. </div>
  35. </header>
  36. <main>
  37. <div class="navs">
  38. <div class="left">
  39. <a href="">PHP开发</a>
  40. <a href="">大前端</a>
  41. <a href="">后端开发</a>
  42. <a href="">数据库</a>
  43. <a href="">移动端</a>
  44. <a href="">运维开发</a>
  45. <a href="">UI设计</a>
  46. <a href="">计算机基础</a>
  47. </div>
  48. <div class="banner">
  49. <a href=""><img src="images/banner.png" alt=""></a>
  50. </div>
  51. <div class="right">
  52. <div class="top">
  53. <a href=""><img src="images/user_avatar.jpg" alt=""></a>
  54. <div class="user">
  55. <p>梦想</p>
  56. <p>P豆 2000</p>
  57. </div>
  58. </div>
  59. <div class="but">
  60. <button>我的学习</button>
  61. </div>
  62. <div class="rigth-bottom">
  63. <!-- <ul class="left">
  64. <li>问答社区</li>
  65. <li>头条</li>
  66. <li>福利</li>
  67. <li>新班</li>
  68. <li>招募</li>
  69. <li>公告</li>
  70. </ul>
  71. <ul class="right">
  72. <li>答疑</li>
  73. <li>66个面试问题,带你梳理MySQL知识点!</li>
  74. <li>限时折扣&gt;&gt;</li>
  75. <li>20期PHP线上班</li>
  76. <li>课程合作计划</li>
  77. <li>APP上线啦!</li>
  78. </ul> -->
  79. <div class="nav">
  80. <a>问答社区</a>
  81. <a>头条</a>
  82. <a>福利</a>
  83. <a>新班</a>
  84. <a>招募</a>
  85. <a>公告</a>
  86. <a>答疑</a>
  87. <a>66个面试问题,带你梳理MySQL知识点!</a>
  88. <a>限时折扣&gt;&gt;</a>
  89. <a>20期PHP线上班</a>
  90. <a>课程合作计划</a>
  91. <a>APP上线啦!</a>
  92. </div>
  93. </div>
  94. </div>
  95. <div class="xxlj">
  96. <div class="desc">
  97. <div class="title">学习路径</div>
  98. <span>全部7个&gt;</span>
  99. </div>
  100. <ul class="detail">
  101. <li onclick="">
  102. <img src="images/dgjj.png" alt="" />
  103. <a href="">独孤九贱</a>
  104. <span>9门课程</span>
  105. </li>
  106. <li onclick="">
  107. <img src="images/ynxj.png" alt="" />
  108. <a href="">独孤九贱</a>
  109. <span>9门课程</span>
  110. </li>
  111. <li onclick="">
  112. <img src="images/tlbb.png" alt="" />
  113. <a href="">独孤九贱</a>
  114. <span>9门课程</span>
  115. </li>
  116. <li onclick="">
  117. <img src="images/zxzn.png" alt="" />
  118. <a href="">独孤九贱</a>
  119. <span>9门课程</span>
  120. </li>
  121. <li onclick="">
  122. <img src="images/xwcg.png" alt="" />
  123. <a href="">独孤九贱</a>
  124. <span>9门课程</span>
  125. </li>
  126. </ul>
  127. </div>
  128. <div class="lxfs">
  129. <div class="wx">
  130. <a href="" class="iconfont icon-weixin wx"></a>
  131. </div>
  132. <span class="wxh">微信公众号</span>
  133. <div class="qq">
  134. <a href="" class="iconfont icon-QQ qq"></a>
  135. </div>
  136. <span class="qqq">官方QQ群</span>
  137. </div>
  138. </div>
  139. </main>

css部分

  1. @import url(reset.css);
  2. @import url(../icon-font/iconfont.css);
  3. header .headertop {
  4. width: 100vw;
  5. background-color: #343434;
  6. }
  7. header .headertop .headercenter {
  8. width: 1200px;
  9. display: grid;
  10. grid-template-columns: 400px 100px;
  11. grid-auto-rows: 40px;
  12. place-content: space-between;
  13. place-items: center start;
  14. margin: auto;
  15. }
  16. header .headertop .headercenter p {
  17. color: rgb(177, 175, 175);
  18. }
  19. header .headertop .haderright {
  20. }
  21. header .headertop .haderright a:first-of-type {
  22. color: #ffffff;
  23. }
  24. header .headertop .haderright img {
  25. width: 50%;
  26. border-radius: 50%;
  27. }
  28. header .headertop .haderright {
  29. display: grid;
  30. grid-template-columns: repeat(2, 1fr);
  31. place-items: center;
  32. }
  33. /* 导航 */
  34. header .navs{
  35. width: 100vw;
  36. height: 90px;
  37. background-color: white;
  38. box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  39. }
  40. header .navs .content{
  41. width: 1200px;
  42. display: grid;
  43. grid-template-columns: 140px 1fr 200px;
  44. grid-auto-rows: 90px;
  45. margin: auto;
  46. gap: 10px;
  47. place-items: center start;
  48. }
  49. header .navs .content img{
  50. width: 120px;
  51. }
  52. /* 导航右侧搜索框 */
  53. header .navs .content .right input{
  54. height: 35px;
  55. width: 200px;
  56. border: none;
  57. outline: none;
  58. background-color: #ebe7e78a;
  59. border-radius: 25px;
  60. text-align: center;
  61. margin-top: 25px;
  62. }
  63. /* 搜索字体图标 */
  64. header .navs .content .right .sousuo{
  65. position: relative;
  66. top: -30px;
  67. left: 170px;
  68. cursor: pointer;
  69. }
  70. header .navs .content nav a{
  71. padding: 0 10px;
  72. }
  73. header .navs .content nav a:hover,
  74. header .navs .content nav a:active,
  75. header .navs .content .right .sousuo:hover{
  76. color: red;
  77. font-weight: bold;
  78. }
  79. /* 中部 */
  80. main{
  81. font-size: 14px;
  82. }
  83. main .navs{
  84. height: 1200px;
  85. display: grid;
  86. grid-template-columns: 140px 810px 190px;
  87. grid-template-rows: 400px 80px;
  88. gap: 10px;
  89. margin: 30px 18%;
  90. }
  91. main .navs *{
  92. background-color: white;
  93. border-radius: 25px;
  94. }
  95. /* 底部学习路径 */
  96. main .navs .xxlj{
  97. grid-column: span 2;
  98. }
  99. main .navs .left{
  100. display: grid;
  101. place-items: center;
  102. }
  103. main .navs .right .top{
  104. display: grid;
  105. grid-template-columns: 40px 1fr;
  106. margin: 40px;
  107. gap: 10px;
  108. }
  109. main .navs .right img{
  110. width: 40px;
  111. }
  112. main .navs .right button{
  113. width: 130px;
  114. height: 30px;
  115. background-color: red;
  116. color: white;
  117. border: none;
  118. outline: none;
  119. margin-left: 20%;
  120. margin-top: -20px;
  121. }
  122. main .navs .right .but{
  123. padding-bottom: 10px;
  124. border-bottom: 1px solid;
  125. border-radius: 0px;
  126. }
  127. /* 底部细节 */
  128. main .navs .xxlj{
  129. display: grid;
  130. grid-template-columns: 100px 1fr;
  131. }
  132. main .navs .xxlj .desc {
  133. padding: 16px 0;
  134. display: grid;
  135. place-items: center;
  136. }
  137. main .navs .xxlj .desc span {
  138. font-size: 12px;
  139. color: #999;
  140. }
  141. main .navs .xxlj .desc span {
  142. font-size: 12px;
  143. color: #999;
  144. }
  145. main .navs .xxlj .detail {
  146. display: flex;
  147. place-items: center;
  148. place-content: space-between;
  149. padding: 20px;
  150. }
  151. main .navs .xxlj .detail li {
  152. display: grid;
  153. grid-template-columns: 36px 85px;
  154. grid-template-columns: repeat(2, 1fr);
  155. gap: 0 10px;
  156. place-items: center start;
  157. }
  158. main .navs .xxlj .detail img {
  159. width: 100%;
  160. grid-row: span 2;
  161. }
  162. main .navs .xxlj .detail li a {
  163. font-size: 14px;
  164. }
  165. main .navs .xxlj .detail li a:hover {
  166. color: red;
  167. }
  168. main .navs .xxlj .detail li span {
  169. font-size: 12px;
  170. color: #999;
  171. }
  172. main .navs .right .rigth-bottom .nav{
  173. display: grid;
  174. grid-template-columns: 80px 1fr;
  175. grid-template-rows: repeat(6,1fr);
  176. grid-auto-flow: column;
  177. place-items: center;
  178. line-height: 13px;
  179. font-size: 12px;
  180. }
  181. main .navs .right .rigth-bottom .nav a:nth-of-type(7){
  182. background-color: red;
  183. color: white;
  184. border-radius: 0px;
  185. }
  186. main .navs .right .rigth-bottom .nav a{
  187. cursor: pointer;
  188. }
  189. main .navs .lxfs{
  190. display: grid;
  191. grid-template-columns: 1fr 1fr;
  192. place-items: center;
  193. }
  194. main .navs .lxfs .wxh{
  195. grid-area: 2;
  196. }
  197. main .navs .lxfs .wx,
  198. main .navs .lxfs .qq{
  199. font-size: 1.5em;
  200. }

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