博客列表 >布局实战代码

布局实战代码

shooter
shooter原创
2022年03月28日 12:57:53527浏览

效果图

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. <link
  8. rel="stylesheet"
  9. href="//at.alicdn.com/t/font_3280886_zb7zws8num9.css"
  10. />
  11. <link rel="stylesheet" href="static/css/1.css" />
  12. <link rel="stylesheet" href="static/css/2.css" />
  13. <link rel="stylesheet" href="static/css/3.css" />
  14. <title>仿php中文网</title>
  15. </head>
  16. <body>
  17. <!-- 页眉 -->
  18. <header>
  19. <!-- 顶部 -->
  20. <div class="top">
  21. <div class="content">
  22. <div class="title">PHP中文网,程序员梦开始的地方!</div>
  23. <div class="right">
  24. <a href="" class="iconfont icon-lingdang"></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"
  33. ><img src="static/images/logo.png" alt=""
  34. /></a>
  35. <nav>
  36. <a href="" class="active">首页</a>
  37. <a href=""
  38. >视频教程<span class="iconfont icon-xiajiankuohao jkh"></span>
  39. </a>
  40. <a href=""
  41. >学习路径<span class="iconfont icon-xiajiankuohao jkh"></span
  42. ></a>
  43. <a href="">php培训</a>
  44. <a href=""
  45. >资源下载<span class="iconfont icon-xiajiankuohao jkh"></span
  46. ></a>
  47. <a href=""
  48. >技术文章<span class="iconfont icon-xiajiankuohao jkh"></span
  49. ></a>
  50. <a href=""
  51. >社区<span class="iconfont icon-xiajiankuohao jkh"></span
  52. ></a>
  53. <a href="" class="iconfont icon-Phoneshouji shouji">APP下载</a>
  54. <a href="" class="iconfont icon-qita"></a>
  55. </nav>
  56. <div class="search">
  57. <input type="search" placeholder="输入关键字搜索" />
  58. <span class="iconfont icon-sousuo fdj"></span>
  59. </div>
  60. </div>
  61. </div>
  62. </header>
  63. <!-- 主题 -->
  64. <main>
  65. <div class="navs">
  66. <!-- 两行三列 -->
  67. <div class="left">
  68. <a href="">php开发</a>
  69. <a href="">大前端</a>
  70. <a href="">后端开发</a>
  71. <a href="">数据库</a>
  72. <a href="">移动端</a>
  73. <a href="">运维开发</a>
  74. <a href="">UI设计</a>
  75. <a href="">计算机基础</a>
  76. </div>
  77. <div class="slider">
  78. <a href=""><img src="static/images/slider.jpeg" alt="" /></a>
  79. </div>
  80. <div class="right">
  81. <div class="des">
  82. <a href=""><img src="static/images/dwtl.jpg" alt="" /></a>
  83. <div class="name">
  84. <a href="">大威天龙</a>
  85. <br /><br />
  86. <span>P豆 8</span>
  87. </div>
  88. <a href="" class="wdxx">我的学习</a>
  89. </div>
  90. <div class="new">
  91. <div class="doc1">
  92. <span>社区问答</span>
  93. <a href="" class="ys">答疑</a>
  94. </div>
  95. <div class="doc2">
  96. <span>头条</span>
  97. <a href="" class="doc">程序员有多好</a>
  98. </div>
  99. <div class="doc3">
  100. <span>新课</span>
  101. <a href="" class="doc">3.9号公益直播课</a>
  102. </div>
  103. <div class="doc4">
  104. <span>新班</span>
  105. <a href="" class="doc">19期PHP直播班</a>
  106. </div>
  107. <div class="doc5">
  108. <span>招募</span>
  109. <a href="" class="doc">课程合作计划</a>
  110. </div>
  111. <div class="doc6">
  112. <span>公告</span>
  113. <a href="" class="doc">APP上线啦</a>
  114. </div>
  115. </div>
  116. </div>
  117. <div class="bottom-left">
  118. <!-- 学习路径 -->
  119. <div class="desc">
  120. <div class="title">学习路径</div>
  121. <span>全部七个&gt;</span>
  122. </div>
  123. <ul class="detail">
  124. <li onclick="">
  125. <img src="static/images/dgjj.png" alt="" />
  126. <a href="">独孤九剑</a>
  127. <span>9门课程</span>
  128. </li>
  129. <li onclick="">
  130. <img src="static/images/ynxj.png" alt="" />
  131. <a href="">玉女心经</a>
  132. <span>5门课程</span>
  133. </li>
  134. <li onclick="">
  135. <img src="static/images/tlbb.png" alt="" />
  136. <a href="">天龙八部</a>
  137. <span>3门课程</span>
  138. </li>
  139. <li onclick="">
  140. <img src="static/images/phpkjkf.png" alt="" />
  141. <a href="">自学指南</a>
  142. <span>19门课程</span>
  143. </li>
  144. <li onclick="">
  145. <img src="static/images/phpksrm.png" alt="" />
  146. <a href="">趣味闯关</a>
  147. <span>22门课程</span>
  148. </li>
  149. </ul>
  150. </div>
  151. <div class="bottom-right">
  152. <div>
  153. <a href="" class="iconfont icon-weixin"></a>
  154. <a href=""><h2>官方公众号</h2></a>
  155. </div>
  156. <div>
  157. <a href="" class="iconfont icon-QQ"></a>
  158. <a href=""><h2>官方QQ群</h2></a>
  159. </div>
  160. </div>
  161. </div>
  162. </main>
  163. </body>
  164. </html>

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. }
  17. `

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: large;
  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. display: grid;
  38. grid-template-columns: 140px 1fr 200px;
  39. grid-auto-rows: 90px;
  40. gap: 20px;
  41. margin: auto;
  42. place-items: center start;
  43. }
  44. header .navs .content img {
  45. width: 100%;
  46. }
  47. header .navs .content nav a.active,
  48. header .navs .content nav a:hover {
  49. color: red;
  50. font-weight: bold;
  51. }
  52. header .navs .content nav span.jkh {
  53. font-size: 10px;
  54. height: 36px;
  55. position: relative;
  56. top: -3px;
  57. left: 5px;
  58. }
  59. header .navs .content nav a.shouji {
  60. color: red;
  61. }
  62. header .navs .content .search {
  63. display: flex;
  64. }
  65. header .navs .content nav a {
  66. padding: 0 13px;
  67. }
  68. header .navs .content .search input[type="search"] {
  69. width: 200px;
  70. height: 36px;
  71. border: none;
  72. background-color: #f7f8fa;
  73. border-radius: 20px;
  74. padding-left: 10px;
  75. }
  76. header .navs .content .search .fdj {
  77. font-size: 22px;
  78. color: #ccc;
  79. position: relative;
  80. left: -40px;
  81. top: 5px;
  82. }
  1. main {
  2. font-size: 14px;
  3. }
  4. main .navs {
  5. /* 两行三列 */
  6. display: grid;
  7. grid-template-columns: 160px 810px 190px;
  8. grid-auto-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. }
  17. /* 底部左侧占两列 */
  18. main .navs .bottom-left {
  19. grid-column: span 2;
  20. }
  21. main .navs .slider img {
  22. width: 100%;
  23. border-radius: 20px;
  24. }
  25. /* 左侧导航 */
  26. main .navs .left {
  27. display: grid;
  28. place-items: center;
  29. padding: 20px 0;
  30. }
  31. main .navs .left a:hover {
  32. color: red;
  33. background-color: rgb(250, 223, 227);
  34. }
  35. main .navs .left a {
  36. border-radius: 20px;
  37. padding: 10px 20px;
  38. }
  39. /* 底部左侧 */
  40. main .navs .bottom-left {
  41. display: grid;
  42. grid-template-columns: 100px 1fr;
  43. }
  44. main .navs .bottom-left .desc {
  45. display: grid;
  46. place-items: center;
  47. padding: 16px;
  48. }
  49. main .navs .bottom-left .detail img {
  50. width: 100%;
  51. grid-row: span 2;
  52. }
  53. main .navs .bottom-left .detail {
  54. display: flex;
  55. place-items: center;
  56. place-content: space-between;
  57. }
  58. main .navs .bottom-left .detail li {
  59. display: grid;
  60. grid-template-columns: 36px 85px;
  61. gap: 0 10px;
  62. place-items: center start;
  63. }
  64. main .navs .bottom-left .detail li a {
  65. font-size: 14px;
  66. }
  67. main .navs .bottom-left .detail li a:hover {
  68. color: red;
  69. }
  70. main .navs .bottom-left .detail li span,
  71. main .navs .bottom-left .desc span {
  72. font-size: 12px;
  73. color: #999;
  74. }
  75. /* 右侧导航 */
  76. main .navs .right {
  77. display: grid;
  78. grid-template-rows: 142px 1fr;
  79. gap: 10px;
  80. }
  81. main .right .des img {
  82. width: 60%;
  83. border-radius: 100%;
  84. margin-left: 18px;
  85. margin-top: 10px;
  86. }
  87. main .right .des {
  88. display: grid;
  89. grid-template-rows: repeat(2, 1fr);
  90. grid-template-columns: repeat(2, 1fr);
  91. place-content: center;
  92. place-items: center center;
  93. background-color: #fff;
  94. border-radius: 10px;
  95. border-bottom: 2px solid #eeeeee;
  96. }
  97. main .right .name {
  98. place-self: center start;
  99. }
  100. main .right .name a {
  101. font-size: large;
  102. font-weight: bold;
  103. }
  104. main .right .name a:hover {
  105. color: red;
  106. }
  107. main .right .name span {
  108. font-size: 14px;
  109. color: #d0d0df;
  110. }
  111. main .right .des .wdxx {
  112. grid-column: span 2;
  113. background-color: #f11717;
  114. width: 150px;
  115. height: 30px;
  116. border-radius: 20px;
  117. padding: auto;
  118. text-align: center;
  119. font-size: large;
  120. font-weight: bold;
  121. color: #fff;
  122. }
  123. main .right .new {
  124. font-size: 15px;
  125. display: grid;
  126. grid-template-rows: repeat(6, 1fr);
  127. background-color: #fff;
  128. border-radius: 20px;
  129. margin-left: 20px;
  130. }
  131. main .right .new .doc1 {
  132. margin-top: 10px;
  133. }
  134. main .right .new .doc1 .ys {
  135. font-size: 13px;
  136. background-color: red;
  137. color: #fff;
  138. }
  139. main .right .new a:hover {
  140. color: red;
  141. }
  142. main .right .new .doc {
  143. color: #999;
  144. }
  145. main .bottom-right {
  146. display: grid;
  147. grid-template-columns: repeat(2, 1fr);
  148. background: #fff;
  149. border-radius: 20px;
  150. gap: 10px;
  151. place-content: space-between;
  152. place-items: center;
  153. padding: 12px;
  154. }
  155. main .bottom-right .iconfont {
  156. font-size: 30px;
  157. border-radius: 100%;
  158. margin: 10px;
  159. color: #fff;
  160. background: #d0d0d0;
  161. }
  162. main .bottom-right a h2 {
  163. font-size: 10px;
  164. }
  165. main .bottom-right a h2:hover {
  166. color: red;
  167. }
上一条:动态框案例下一条:模态框案例
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议