Blogger Information
Blog 19
fans 0
comment 0
visits 10684
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php.cn右侧布局
期待.
Original
347 people have browsed it

前言:虽然样子多多少少是做出来了,但是确实代码写的很乱,也是希望各位指出我代码中的一些问题!

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. <title>grid: 仿PHP.CN首页</title>
  8. <!-- <link rel="stylesheet" href="icon-font.css" /> -->
  9. <link rel="stylesheet" href="https://at.alicdn.com/t/font_3205780_7eqow85axa.css" />
  10. <link rel="stylesheet" href="static/css/header.css" />
  11. <link rel="stylesheet" href="static/css/main-nav.css" />
  12. <link rel="stylesheet" href="./font_3511886_v5kw9xhio/iconfont.css">
  13. </head>
  14. <body>
  15. <!-- 页眉 -->
  16. <header>
  17. <!-- 顶部 -->
  18. <div class="top">
  19. <div class="content">
  20. <!-- 左边:顶部标题 -->
  21. <div class="title">php中文网,程序员梦开始的地方!</div>
  22. <!-- 右边: 用户信息 -->
  23. <div class="right">
  24. <a href="" class="iconfont icon-tixingtianchong"></a>
  25. <a href=""><img src="static/images/user-pic.jpeg" alt="" /></a>
  26. </div>
  27. </div>
  28. </div>
  29. <!-- 导航 -->
  30. <div class="navs">
  31. <div class="content">
  32. <a href="" class="logo"><img src="static/images/logo.png" alt="" /></a>
  33. <nav>
  34. <a href="" class="active">首页</a>
  35. <a href="">视频教程</a>
  36. <a href="">学习路径</a>
  37. <a href="">php培训</a>
  38. <a href="">资源下载</a>
  39. </nav>
  40. <div class="search">
  41. <input type="search" placeholder="输入关键字" />
  42. <span class="iconfont icon-fangdajing1"></span>
  43. </div>
  44. </div>
  45. </div>
  46. </header>
  47. <!-- 主体 -->
  48. <main>
  49. <div class="navs">
  50. <div class="left">
  51. <a href="">php开发</a>
  52. <a href="">大前端</a>
  53. <a href="">后端开发</a>
  54. <a href="">数据库</a>
  55. <a href="">移动端</a>
  56. <a href="">运维开发</a>
  57. <a href="">UI设计</a>
  58. <a href="">计算机基础</a>
  59. </div>
  60. <div class="slider">
  61. <a href=""><img src="static/images/slider.jpeg" alt="" /></a>
  62. </div>
  63. <div class="right">
  64. <div class="content">
  65. <a href=""><img src="static/images/user-pic.jpeg" alt=""></a>
  66. <a href="" style="color:#333333; float: left; font-weight:bold;">朱老师</a>
  67. <a href="">P豆:2000</a>
  68. </div>
  69. <div class="aniu">
  70. <a href="">我的学习</a>
  71. </div>
  72. <div style="border-bottom: 1px solid #eeeeee; margin-top: 30px;"></div>
  73. <div class="right-zhong">
  74. <div>问答社区</div>
  75. <a href="">答疑</a>
  76. </div>
  77. <div class="right-xia">
  78. <div>头条</div>
  79. <a href="">新闻</a>
  80. <div>福利</div>
  81. <a href="">限时折扣>></a>
  82. <div>新班</div>
  83. <a href="">20期PHP</a>
  84. <div>招募</div>
  85. <a href="">课程合作计划</a>
  86. <div>公告</div>
  87. <a href="">APP上线啦</a>
  88. </div>
  89. </div>
  90. <div class="bottom-left">
  91. <div class="desc">
  92. <div class="title">学习路径</div>
  93. <span>全部7个&gt;</span>
  94. </div>
  95. <ul class="detail">
  96. <li onclick="">
  97. <img src="static/images/dgjj.png" alt="" />
  98. <a href="">独孤九贱</a>
  99. <span>9门课程</span>
  100. </li>
  101. <li onclick="">
  102. <img src="static/images/ynxj.png" alt="" />
  103. <a href="">独孤九贱</a>
  104. <span>9门课程</span>
  105. </li>
  106. <li onclick="">
  107. <img src="static/images/tlbb.png" alt="" />
  108. <a href="">独孤九贱</a>
  109. <span>9门课程</span>
  110. </li>
  111. <li onclick="">
  112. <img src="static/images/phpkjkf.png" alt="" />
  113. <a href="">独孤九贱</a>
  114. <span>9门课程</span>
  115. </li>
  116. <li onclick="">
  117. <img src="static/images/phpksrm.png" alt="" />
  118. <a href="">独孤九贱</a>
  119. <span>9门课程</span>
  120. </li>
  121. </ul>
  122. </div>
  123. <div class="bottom-right">
  124. <span class="iconfont icon-weibo-circle-fill"></span>
  125. <span class="iconfont icon-QQ-circle-fill"></span>
  126. <a href="">官方公众号</a>
  127. <a href="">官方QQ群</a>
  128. </div>
  129. </div>
  130. </main>
  131. </body>
  132. </html>

3.CSS代码

  1. main {
  2. /* 因为浏览器默认是16px, 16有点大 */
  3. font-size: 14px;
  4. }
  5. main .navs {
  6. /* 2行3列 */
  7. display: grid;
  8. grid-template-rows: 400px 80px;
  9. grid-template-columns: 160px 810px 190px;
  10. gap: 20px;
  11. place-content: center;
  12. margin: 30px 0;
  13. }
  14. /* 统一样式,完成后可看到基本框架 */
  15. main .navs > * {
  16. background-color: #fff;
  17. border-radius: 20px;
  18. }
  19. /* 底部左边占2列 */
  20. main .navs .bottom-left {
  21. grid-column: span 2;
  22. }
  23. /* 整体布局完成,剩下就是细节了 */
  24. /* 上部左边导航 */
  25. main .navs .left {
  26. padding: 20px 0;
  27. /* grid: 默认每个项目都是"块级", 垂直排列 */
  28. /* flex: 默认每个项目都是"行内块级", 水平排列 */
  29. display: grid;
  30. /* 当前项目在每个网络单元中, 垂直,水平均居中 */
  31. /* place-items: 垂直方向 水平方向; */
  32. place-items: center;
  33. }
  34. main .navs .left a {
  35. padding: 10px 20px;
  36. }
  37. main .navs .left a:hover {
  38. border-radius: 20px;
  39. color: red;
  40. background-color: rgb(250, 223, 227);
  41. }
  42. /* 轮播图,单图模拟 */
  43. main .navs .slider img {
  44. width: 100%;
  45. border-radius: 20px;
  46. }
  47. /* 底部左侧 */
  48. main .navs .bottom-left {
  49. display: grid;
  50. grid-template-columns: 100px 1fr;
  51. }
  52. main .navs .bottom-left .desc {
  53. padding: 16px 0;
  54. display: grid;
  55. place-items: center;
  56. }
  57. main .navs .bottom-left .desc span {
  58. font-size: 12px;
  59. color: #999;
  60. }
  61. main .navs .bottom-left .detail {
  62. display: flex;
  63. place-items: center;
  64. place-content: space-between;
  65. padding: 20px;
  66. }
  67. main .navs .bottom-left .detail li {
  68. display: grid;
  69. grid-template-columns: 36px 85px;
  70. grid-template-columns: repeat(2, 36);
  71. gap: 0 10px;
  72. place-items: center start;
  73. }
  74. main .navs .bottom-left .detail img {
  75. width: 100%;
  76. grid-row: span 2;
  77. }
  78. main .navs .bottom-left .detail li a {
  79. font-size: 14px;
  80. }
  81. main .navs .bottom-left .detail li a:hover {
  82. color: red;
  83. }
  84. main .navs .bottom-left .detail li span {
  85. font-size: 12px;
  86. color: #999;
  87. }
  88. main .navs .right .content {
  89. display: grid;
  90. grid-template-columns:repeat(2,1fr);
  91. grid-template-rows:repeat(2,1fr);
  92. grid-row: 1 / span 2;
  93. /* place-items: center start; */
  94. }
  95. main .navs .right .content a:nth-of-type(1) {
  96. grid-row: 1 / span 2;
  97. place-self:center center;
  98. padding: 10px;
  99. }
  100. main .navs .right .content a:nth-of-type(2) {
  101. place-self:center start;
  102. }
  103. main .navs .right .content img {
  104. border-radius: 100px;
  105. width: 60px;
  106. }
  107. main .navs .right .aniu > a {
  108. display: block;
  109. background: #f11717;
  110. padding: 10px;
  111. width: 150px;
  112. height: 40px;
  113. border-radius: 30px;
  114. margin-left: 22px;
  115. text-align: center;
  116. color: #ffffff;
  117. }
  118. main .navs .right .right-zhong {
  119. display: flex;
  120. width: 200px;
  121. padding: 15px;
  122. place-content:space-evenly;
  123. }
  124. main .navs .right .right-zhong a {
  125. background: #ff583d;
  126. color:#ffffff;
  127. border-radius: 2px;
  128. }
  129. main .navs .right .right-xia {
  130. display: grid;
  131. grid-template-rows: repeat(5,1fr);
  132. grid-template-columns: repeat(2,1fr);
  133. /* width: 200px; */
  134. place-items: center start;
  135. }
  136. main .navs .right .right-xia > div {
  137. /* background-color: red; */
  138. margin: 5px;
  139. padding: 5px;
  140. }
  141. main .navs .right .right-xia > a:hover {
  142. color: red;
  143. }
  144. main .navs .right .right-xia > a {
  145. outline: none;
  146. color: #b6b6b6
  147. }
  148. main .navs .bottom-right {
  149. display: grid;
  150. grid-template-rows: repeat(2,1fr);
  151. grid-template-columns: repeat(2,1fr);
  152. place-items: center;
  153. }
  154. main .navs .bottom-right span {
  155. font-size: 35px;
  156. padding: 5px;
  157. }
  158. main .navs .bottom-right a {
  159. margin-bottom: 7px;
  160. font-weight: bold;
  161. }
  162. main .navs .bottom-right a:hover {
  163. color: red;
  164. outline: none;
  165. }
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post