Blogger Information
Blog 47
fans 1
comment 0
visits 40486
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php.cn头部右侧的布局
新手1314
Original
613 people have browsed it

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/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.jpg" 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="dibu">
  65. <div class="right-header">
  66. <div class="right-header-img">
  67. <a href=""><img src="static/images/user.jpg" alt="" /></a>
  68. </div>
  69. <div class="right-header-xs">新手1314</div>
  70. <div class="right-header-pd">P豆:86</div>
  71. </div>
  72. <div class="anniu">
  73. <a href="">我的学习</a>
  74. </div>
  75. </div>
  76. <div class="gonggao">
  77. <div class="wenda">
  78. 问答社区
  79. <a href="">答疑</a>
  80. </div>
  81. <div class="toutiao">
  82. <span>头条</span>
  83. <a href="">2022年最流行的11款PHP框架</a>
  84. </div>
  85. <div class="fuli">
  86. <span>福利</span>
  87. <a href="">限时折扣>></a>
  88. </div>
  89. <div class="xinban">
  90. <span>新班</span>
  91. <a href="">20期PHP线上班</a>
  92. </div>
  93. <div class="zhaomu">
  94. <span>招募</span>
  95. <a href="">课程合作计划</a>
  96. </div>
  97. <div class="gongg">
  98. <span>公告</span>
  99. <a href="">APP上线啦</a>
  100. </div>
  101. </div>
  102. </div>
  103. <div class="bottom-left">
  104. <div class="desc">
  105. <div class="title">学习路径</div>
  106. <span>全部7个&gt;</span>
  107. </div>
  108. <ul class="detail">
  109. <li onclick="">
  110. <img src="static/images/dgjj.png" alt="" />
  111. <a href="">独孤九贱</a>
  112. <span>9门课程</span>
  113. </li>
  114. <li onclick="">
  115. <img src="static/images/ynxj.png" alt="" />
  116. <a href="">独孤九贱</a>
  117. <span>9门课程</span>
  118. </li>
  119. <li onclick="">
  120. <img src="static/images/tlbb.png" alt="" />
  121. <a href="">独孤九贱</a>
  122. <span>9门课程</span>
  123. </li>
  124. <li onclick="">
  125. <img src="static/images/phpkjkf.png" alt="" />
  126. <a href="">独孤九贱</a>
  127. <span>9门课程</span>
  128. </li>
  129. <li onclick="">
  130. <img src="static/images/phpksrm.png" alt="" />
  131. <a href="">独孤九贱</a>
  132. <span>9门课程</span>
  133. </li>
  134. </ul>
  135. </div>
  136. <div class="bottom-right">
  137. <div class="tubiao"><span class="iconfont icon-logo-wechat"></span></div>
  138. <div class="tubiao"><span class="iconfont icon-QQ-circle-fill"></span></div>
  139. <div class="zitiwx">官方公众号</div>
  140. <div class="zitiqq">官方QQ号</div>
  141. </div>
  142. </div>
  143. </main>
  144. </body>
  145. </html>

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 .right-header {
  89. padding: 10px;
  90. height: 60px;
  91. display: grid;
  92. grid-template-columns: 50px 140px;
  93. grid-template-rows: 30px 30px;
  94. }
  95. main .navs .right .right-header img {
  96. width: 40px;
  97. height: 40px;
  98. background-color: #fff;
  99. /* grid-row: 1/2; */
  100. border-radius: 20px;
  101. /* place-items: end end; */
  102. }
  103. main .navs .right .right-header .right-header-img {
  104. grid-area: 1/1 / span 2 / span 1;
  105. place-self: center end;
  106. margin-top: 5px;
  107. }
  108. main .navs .right .right-header .right-header-xs {
  109. margin-top: 5px;
  110. margin-left: 10px;
  111. font-weight: bold;
  112. }
  113. main .navs .right .right-header .right-header-xs:hover {
  114. cursor: pointer;
  115. color: red;
  116. }
  117. main .navs .right .right-header .right-header-pd {
  118. margin-top: 5px;
  119. margin-left: 10px;
  120. color: #999999;
  121. font-size: 8px;
  122. }
  123. main .navs .right .anniu a {
  124. display: block;
  125. color: #fff;
  126. background-color: red;
  127. border-radius: 100px;
  128. width: 150px;
  129. height: 34px;
  130. text-align: center;
  131. line-height: 34px;
  132. margin-top: 20px;
  133. margin-left: 20px;
  134. }
  135. main .navs .right .anniu a:hover {
  136. background-color: #e11717;
  137. }
  138. main .navs .right .dibu {
  139. height: 190px;
  140. height: 141px;
  141. border-bottom: 1px solid #eeeeee;
  142. }
  143. main .navs .right .gonggao {
  144. width: 150px;
  145. margin: auto;
  146. padding-top: 7px;
  147. }
  148. main .navs .right .gonggao .wenda {
  149. height: 18px;
  150. line-height: 18px;
  151. margin-top: 17px;
  152. }
  153. main .navs .right .gonggao .wenda a {
  154. display: inline-block;
  155. width: 31px;
  156. height: 16px;
  157. background-color: #ff583d;
  158. border-radius: 2px;
  159. font-size: 12px;
  160. color: #fff;
  161. line-height: 16px;
  162. text-align: center;
  163. margin-left: 10px;
  164. }
  165. main .navs .right .gonggao .toutiao {
  166. height: 41px;
  167. margin-top: 17px;
  168. }
  169. main .navs .right .gonggao .fuli,
  170. main .navs .right .gonggao .xinban,
  171. main .navs .right .gonggao .zhaomu,
  172. main .navs .right .gonggao .gongg {
  173. height: 18px;
  174. line-height: 18px;
  175. margin-top: 17px;
  176. }
  177. main .navs .right .gonggao .toutiao a,
  178. main .navs .right .gonggao .fuli a,
  179. main .navs .right .gonggao .xinban a,
  180. main .navs .right .gonggao .zhaomu a,
  181. main .navs .right .gonggao .gongg a {
  182. display: block;
  183. width: 108px;
  184. float: right;
  185. color: #b6b6b6;
  186. }
  187. main .navs .right .gonggao .toutiao a:hover,
  188. main .navs .right .gonggao .fuli a:hover,
  189. main .navs .right .gonggao .xinban a:hover,
  190. main .navs .right .gonggao .zhaomu a:hover,
  191. main .navs .right .gonggao .gongg a:hover {
  192. color: red;
  193. text-decoration: underline;
  194. }
  195. main .navs .bottom-right {
  196. display: grid;
  197. grid-template-columns: 95px 95px;
  198. grid-template-rows: 50px 30px;
  199. }
  200. main .navs .bottom-right .tubiao {
  201. margin-top: 5px;
  202. place-self: center center;
  203. }
  204. main .navs .bottom-right .iconfont.icon-logo-wechat,
  205. main .navs .bottom-right .iconfont.icon-QQ-circle-fill {
  206. /* margin-left: -2px; */
  207. font-size: 33px;
  208. color: #b6b6b6;
  209. }
  210. main .navs .bottom-right .iconfont.icon-QQ-circle-fill {
  211. margin-left: -20px;
  212. }
  213. main .navs .bottom-right .zitiwx,
  214. main .navs .bottom-right .zitiqq {
  215. margin-left: -5px;
  216. margin-top: 2px;
  217. font-size: 12px;
  218. font-weight: bold;
  219. text-align: center;
  220. }
  221. main .navs .bottom-right .zitiqq {
  222. margin-left: -20px;
  223. }
  224. main .navs .bottom-right .zitiwx:hover,
  225. main .navs .bottom-right .zitiqq:hover {
  226. cursor: pointer;
  227. color: red;
  228. }
  229. main .navs .bottom-right .iconfont.icon-logo-wechat:hover,
  230. main .navs .bottom-right .iconfont.icon-QQ-circle-fill:hover {
  231. cursor: pointer;
  232. }
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