博客列表 >仿写一个首页

仿写一个首页

三九三伏
三九三伏原创
2022年07月18日 09:41:17319浏览

1. 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. <title>Document</title>
  8. <link rel="stylesheet" href="static/css/reset.css">
  9. <link rel="stylesheet" href="icon-font.css">
  10. <link rel="stylesheet" href="static/css/style.css">
  11. </head>
  12. <body>
  13. <!-- 页眉 -->
  14. <header>
  15. <!-- 顶部 -->
  16. <div class="top">
  17. <div class="content">
  18. <!-- 左边:顶部文字 -->
  19. <div class="title">php中文网-程序员梦开始的地方</div>
  20. <!-- 右边:用户信息 -->
  21. <div class="right">
  22. <a href="" class="iconfont icon-tixingtianchong"></a>
  23. <a href=""><img src="static/img/ET.jpg" alt="" ></a>
  24. </div>
  25. </div>
  26. </div>
  27. <!-- 导航 -->
  28. <div class="navs">
  29. <div class="content">
  30. <a href="" class="logo"><img src="php.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-fangdajing1"></span>
  41. </div>
  42. </div>
  43. </div>
  44. </header>
  45. <!-- 主体 -->
  46. <main>
  47. <div class="grid">
  48. <div class="r1c1">
  49. <a href="">php开发</a>
  50. <a href="">大前端</a>
  51. <a href="">后端开发</a>
  52. <a href="">数据库</a>
  53. <a href="">移动端</a>
  54. <a href="">运维开发</a>
  55. <a href="">UI设计</a>
  56. <a href="">计算机基础</a>
  57. </div>
  58. <div class="r1c2">
  59. <a href=""><img src="static/img/xszbb.png" alt=""></a>
  60. <!-- <a href=""><img src="static/img/kqhz.jpg" alt=""></a>
  61. <a href=""><img src="static/img/appsxl.jpg" alt=""></a>
  62. <a href=""><img src="static/img/mtjbydd.jpg" alt=""></a> -->
  63. </div>
  64. <div class="r1c3">
  65. <div class="r1c3top">
  66. <div class="toptop">
  67. <a href=""><img src="static/img/ET.jpg" alt=""></a>
  68. <strong>Mr xxx</strong>
  69. <div>
  70. <em>P豆<span>18</span></em>
  71. </div>
  72. </div>
  73. <a class="xuexi" href="" >我的学习</a>
  74. </div>
  75. <div class="r1c3bottom">
  76. <div class="b1">
  77. <strong>问答社区</strong>
  78. <span>答疑</span>
  79. </div>
  80. <div class="b2">
  81. <strong>头条</strong>
  82. <span>头条内容</span>
  83. </div>
  84. <div class="b3">
  85. <strong>福利</strong>
  86. <span>福利内容</span>
  87. </div>
  88. <div class="b4">
  89. <strong>新班</strong>
  90. <span>新班内容</span>
  91. </div>
  92. <div class="b5">
  93. <strong>招募</strong>
  94. <span>招募内容</span>
  95. </div>
  96. <div class="b6">
  97. <strong>公告</strong>
  98. <span>公告内容</span>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="r2c1">
  103. <div class="desc">
  104. <div class="title">学习路径</div>
  105. <span>全部7个&gt;</span>
  106. </div>
  107. <ul class="detail">
  108. <li onclick="">
  109. <img src="static/img/dgjj.png" alt="">
  110. <a href="">独孤九剑</a>
  111. <span>9门课程</span>
  112. </li>
  113. <li onclick="">
  114. <img src="static/img/ynxj.png" alt="">
  115. <a href="">玉女心经</a>
  116. <span>5门课程</span>
  117. </li>
  118. <li onclick="">
  119. <img src="static/img/tlbb.png" alt="">
  120. <a href="">天龙八部</a>
  121. <span>3门课程</span>
  122. </li>
  123. <li onclick="">
  124. <img src="static/img/phpkjkf.png" alt="">
  125. <a href="">自学指南</a>
  126. <span>19门课程</span>
  127. </li>
  128. <li onclick="">
  129. <img src="static/img/phpksrm.png" alt="">
  130. <a href="">趣味闯关</a>
  131. <span>22门课程</span>
  132. </li>
  133. <!-- <li onclick="">
  134. <img src="static/img/web.png" alt="">
  135. <a href="">入门课程</a>
  136. <span>22门课程</span>
  137. </li>
  138. <li onclick="">
  139. <img src="static/img/phpsz.png" alt="">
  140. <a href="">PHP直播班</a>
  141. <span>三个阶段</span>
  142. </li> -->
  143. </ul>
  144. </div>
  145. <div class="r2c2">
  146. <div class="r2c2left">
  147. <a href=""><img src="php.png" alt=""></a>
  148. <span>官方公众号</span>
  149. </div>
  150. <div class="r2c2right">
  151. <a href=""><img src="php.png" alt=""></a>
  152. <span>官方QQ群</span>
  153. </div>
  154. </div>
  155. </div>
  156. </main>
  157. </body>
  158. </html>

2. style.css代码

  1. body{
  2. background-color: #f3f5f7;
  3. }
  4. header .top{
  5. width: 100vw;
  6. height: 40px;
  7. background-color: #343434;
  8. color: #aaa;
  9. }
  10. header .top .content{
  11. width: 1200px;
  12. display: grid;
  13. grid-template-columns: 400px 100px;
  14. place-content: space-between;
  15. place-items: center start;
  16. grid-auto-rows: 40px;
  17. margin: auto;
  18. }
  19. header .top .content .right .iconfont{
  20. color: #eee;
  21. font-size:larger;
  22. }
  23. header .top .content .right>a>img{
  24. width: 50%;
  25. border-radius: 50%;
  26. }
  27. header .top .content .right{
  28. display: grid;
  29. grid-template-columns: repeat(2,1fr);
  30. place-items: center start;
  31. }
  32. header .top .title{
  33. font-size: larger;
  34. font-weight: bold;
  35. }
  36. header .navs{
  37. width: 100vw;
  38. height: 90px;
  39. background-color: #fff;
  40. box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  41. }
  42. header .navs .content{
  43. width: 1200px;
  44. display: grid;
  45. grid-template-columns: 140px 1fr 200px;
  46. margin:auto;
  47. gap:10px;
  48. grid-auto-rows:90px;
  49. place-items: center start;
  50. }
  51. header .navs .content nav{
  52. display: flex;
  53. }
  54. header .navs .content nav a{
  55. padding: 0 10px;
  56. }
  57. header .navs .content nav a:hover,
  58. header .navs .content nav a.active{
  59. font-weight: bold;
  60. color: red;
  61. }
  62. header .navs .content img{
  63. width: 100%;
  64. height: 90px;
  65. box-shadow: 0 5px 5px rgba(1,0,0,0.8);
  66. }
  67. header .navs .content .search{
  68. display: flex;
  69. }
  70. header .navs .content .search input[type="search"]{
  71. width: 200px;
  72. height: 36px;
  73. border: none;
  74. background-color: #f0f0f0;
  75. outline: none;
  76. border-radius: 10px;
  77. padding-left: 15%;
  78. }
  79. header .navs .content .search .icon-fangdajing1{
  80. font-size:20px;
  81. color: #ccc;
  82. position: relative;
  83. left: -40px;
  84. top: 8px;
  85. }
  86. header .navs .content .search .icon-fangdajing1:hover{
  87. cursor: pointer;
  88. color: #0f0f0f;
  89. }
  90. main{
  91. /* 浏览器默认16px字体有点大 */
  92. font-size: 14px;
  93. }
  94. main .grid{
  95. /* 调试用的定位色 */
  96. /* background-color: lightcyan; */
  97. display: grid;
  98. grid-template-columns: 160px 810px 190px;
  99. grid-template-rows: 400px 80px;
  100. gap: 20px;
  101. place-content: center;
  102. margin: 20px 0;
  103. }
  104. main .grid> *{
  105. background-color: #ffffff;
  106. border-radius: 5px;
  107. }
  108. main .grid .r2c1{
  109. grid-column: span 2;
  110. }
  111. main .grid .r1c1{
  112. padding: 20px 0px;
  113. display: grid;
  114. place-items: center;
  115. }
  116. main .grid .r1c1>a{
  117. padding: 10px 20px;
  118. }
  119. main .grid .r1c1>a:hover{
  120. color: red;
  121. border-radius: 10px;
  122. background-color: rgb(250, 223, 270);
  123. }
  124. main .grid .r1c2 img{
  125. width: 100%;
  126. border-radius: 10px;
  127. }
  128. main .grid .r2c1{
  129. display: grid;
  130. grid-template-columns: 100px 1fr;
  131. }
  132. main .grid .r2c1 .desc{
  133. padding: 16px 0;
  134. display: grid;
  135. place-items: center;
  136. }
  137. main .grid .r2c1 .desc span{
  138. font-size: 12px;
  139. color: #999;
  140. }
  141. main .grid .r2c1 .detail{
  142. display: flex;
  143. place-items: center;
  144. place-content: space-between;
  145. padding 20px 0;
  146. }
  147. main .grid .r2c1 .detail li{
  148. display: grid;
  149. grid-template-columns: 36px 85px;
  150. grid-template-columns: repeat(2,36);
  151. gap: 0 10px;
  152. place-items: center start;
  153. }
  154. main .grid .r2c1 .detail li img{
  155. width:100%;
  156. grid-row: span 2;
  157. }
  158. main .grid .r2r1 .detail li a{
  159. font-size: 14px;
  160. }
  161. main .grid .r2c1 .detail li a:hover{
  162. color: red;
  163. }
  164. main .grid .r2c1 .detail li span{
  165. font-size: 12px;
  166. color: #999;
  167. }
  168. main .grid .r1c3{
  169. display: grid;
  170. grid-template-rows: 200px 200px;
  171. padding: 2px;
  172. }
  173. main .grid .r1c3 .r1c3top{
  174. display: grid;
  175. grid-template-rows: 100px 100px;
  176. /* gap 10px 0; */
  177. place-content: space-between;
  178. place-items: center start;
  179. border-bottom: 1px solid #eee;
  180. }
  181. main .grid .r1c3 .r1c3top .toptop{
  182. display: grid;
  183. grid-template-columns: 60px 110px;
  184. gap: 0px 10px;
  185. place-content: space-between;
  186. place-items: center;
  187. }
  188. main .grid .r1c3 .r1c3top .toptop a{
  189. grid-row: span 2;
  190. }
  191. main .grid .r1c3 .r1c3top .toptop img{
  192. width: 100%;
  193. border-radius: 100px;
  194. }
  195. main .grid .r1c3 .r1c3top .xuexi{
  196. place-content: top center;
  197. /* place-items: center; */
  198. margin-bottom: 100px;
  199. width: 90%;
  200. height: 35%;
  201. background-color: red;
  202. border-radius: 10px;
  203. text-align: center ;
  204. padding-top: 10px;
  205. color: #fff;
  206. font-weight: bold;
  207. }
  208. main .grid .r1c3 .r1c3bottom{
  209. padding: 10px;
  210. display: grid;
  211. grid-template-rows: 30px 30px 30px 30px 30px 30px;
  212. gap: 1px 0;
  213. }
  214. main .grid .r1c3 .r1c3bottom div{
  215. display: grid;
  216. grid-template-columns: 80px 80px;
  217. }
  218. main .grid .r1c3 .r1c3bottom div span{
  219. color: #999;
  220. }
  221. main .grid .r2c2{
  222. display:grid;
  223. grid-template-columns: 90px 90px;
  224. place-content: space-between;
  225. }
  226. main .grid .r2c2 div{
  227. display: grid;
  228. grid-template-rows: 40px 40px;
  229. place-items: center;
  230. }
  231. main .grid .r2c2 div img{
  232. align-items: center;
  233. padding: 10px;
  234. width: 40px;
  235. height: 40px;
  236. }

3. reset.css代码

  1. *{
  2. margin: 0;
  3. padding: 0;
  4. box-sizing: border-box;
  5. }
  6. a{
  7. text-decoration: none;
  8. color: #555;
  9. }
  10. body{
  11. background-color: rgb(243.245,247);
  12. }
  13. li{
  14. list-style: none;
  15. }

4. icon-font.css代码

  1. @font-face {
  2. /*引入的字体,可在阿里自行下载。*/
  3. font-family: "iconfont"; /* Project id 3205780 */
  4. src: url(./font_3205780_7eqow85axa.woff2) format('woff2'),
  5. url(./font_3205780_7eqow85axa.woff) format('woff'),
  6. url(./font_3205780_7eqow85axa.ttf) format('truetype');
  7. }
  8. .iconfont {
  9. font-family: "iconfont" !important;
  10. font-size: 16px;
  11. font-style: normal;
  12. -webkit-font-smoothing: antialiased;
  13. -moz-osx-font-smoothing: grayscale;
  14. }
  15. .icon-tixingtianchong:before {
  16. content: "\e695";
  17. }
  18. .icon-fangdajing1:before {
  19. content: "\e609";
  20. }
  21. .icon-fangdajing:before {
  22. content: "\e60c";
  23. }
  24. .icon-gouwuche:before {
  25. content: "\e899";
  26. }
  27. .icon-wodetaobao:before {
  28. content: "\e61b";
  29. }
  30. .icon-rmb:before {
  31. content: "\e6b0";
  32. }
  33. .icon-xiantiao-:before {
  34. content: "\e600";
  35. }
  36. .icon-aixin:before {
  37. content: "\e6ec";
  38. }
  39. .icon-shejiaotubiao-08:before {
  40. content: "\e641";
  41. }
  42. .icon-shejiaotubiao-44:before {
  43. content: "\e648";
  44. }

5. 效果展示


感觉仿的还可以,自己偷偷开心下,不过代码肯定不够精简,希望后面可以通过学习优化。

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