博客列表 >练习PHP中文网首页

练习PHP中文网首页

newbie
newbie原创
2022年03月27日 22:07:36432浏览

php中文网

并不是完全使用的grid布局 还使用了浮动 定位 flex

代码复用性太差 逻辑不够清晰 代码熟练度不够 在网页编写中经常卡壳 不能熟练运用现有的技术 需要在借助手册的情况下才能完成

效果图

代码

  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>Document</title>
  8. <link rel="preload" href="//at.alicdn.com/t/font_3280490_qvzagyi0dm.woff2" as="font" type="font/woff2" crossorigin="anonymous">
  9. <link rel="stylesheet" href="//at.alicdn.com/t/font_3280490_su2mgd3iph.css"/>
  10. <link rel="stylesheet" href="/220324/作业/css/hrad.css"/>
  11. <link rel="stylesheet" href="/220324/作业/css/main.css"/>
  12. </head>
  13. <body>
  14. <!-- 头部样式 -->
  15. <header>
  16. <div class="head">
  17. <div class="top">
  18. <div class="top-left">php中文网-程序员梦开始的地方!</div>
  19. <div class="top-right">
  20. <a href="" class="iconfont icon-tixing" ></a>
  21. <a href=""><img src="https://img.php.cn/upload/image/865/925/445/1648305289782816.jpg"></a>
  22. </div>
  23. </div>
  24. </div>
  25. <!-- 导航 -->
  26. <div class="daohang">
  27. <div class="phpcenter">
  28. <div class="logo">
  29. <a href=""><img src="https://www.php.cn/static/images/new/logo.png"></a>
  30. </div>
  31. <nav>
  32. <a href="">
  33. <h2>首页</h2>
  34. </a>
  35. <a href="">
  36. <h2>视频教程</h2>
  37. <b class="iconfont icon-xiajiantou"></b>
  38. </a>
  39. <a href="">
  40. <h2>学习路径</h2>
  41. <b class="iconfont icon-xiajiantou"></b>
  42. </a>
  43. <a href="">
  44. <h2>php培训</h2>
  45. <b class="xin"></b>
  46. </a>
  47. <a href="">
  48. <h2>资源下载</h2>
  49. <b class="iconfont icon-xiajiantou"></b>
  50. </a>
  51. <a href="">
  52. <h2>技术文章</h2>
  53. <b class="iconfont icon-xiajiantou"></b>
  54. </a>
  55. <a href="">
  56. <h2>社区</h2>
  57. <b class="iconfont icon-xiajiantou shequ"></b>
  58. </a>
  59. <a href="">
  60. <b class="iconfont icon-shouji"></b>
  61. <h2 class="appxiazai">&nbsp&nbsp&nbsp&nbspAPP下载</h2>
  62. </a>
  63. <a href="">
  64. <b class="iconfont icon-shenglvehao"></b>
  65. </a>
  66. </nav>
  67. <div class="daohang-right">
  68. <input type="search" placeholder="请输入搜索内容"/>
  69. <span class="iconfont icon-search"></span>
  70. </div>
  71. </div>
  72. </div>
  73. </header>
  74. <!-- 主体区域 -->
  75. <main>
  76. <div class="zhukuang">
  77. <div class="main-left">
  78. <a href="">php开发</a>
  79. <a href="">大前端</a>
  80. <a href="">后端开发</a>
  81. <a href="">数据库</a>
  82. <a href="">移动端</a>
  83. <a href="">运维开发</a>
  84. <a href="">UI设计</a>
  85. </div>
  86. <div class="main-center">
  87. <a>
  88. <img src="/220324/img/course.jpg">
  89. </a>
  90. </div>
  91. <div class="main-right">
  92. <div class="main-right-top">
  93. <div class="right-top-top">
  94. <a href=""><img src="https://img.php.cn/upload/image/865/925/445/1648305289782816.jpg"></a>
  95. <dl>
  96. <a href="">
  97. <dt>newbie</dt>
  98. <b class="iconfont icon-tipvip"></b>
  99. </a>
  100. <dd>P豆 14</dd>
  101. </dl>
  102. </div>
  103. <div class="right-top-bottom"><a href="" style="color: white;">我的学习</a></div>
  104. </div>
  105. <div class="main-right-bottom">
  106. <p class="p1"><span>问答社区</span><a href="">答疑</a></p>
  107. <p class="p2"><span>头条</span><a href="">我的天哪</a></p>
  108. <p class="p3"><span>新课</span><a href="">3.9号公益直播课</a></p>
  109. <p class="p4"><span>新班</span><a href="">19期PHP直播班</a></p>
  110. <p class="p5"><span>招募</span><a href="">课程合作计划</a></p>
  111. <p class="p6"><span>公告</span><a href="">APP上线啦</a></p>
  112. </div>
  113. </div>
  114. <div class="main-bottom-left">
  115. <div class="bottom-left-left">
  116. <dl>
  117. <dt>学习路径</dt>
  118. <dd>全部7个&gt;</dd>
  119. </dl>
  120. </div>
  121. <a href="">
  122. <img src="https://www.php.cn/static/images/examples/dgjj.png" alt="">
  123. <dl>
  124. <dt>独孤九贱</dt>
  125. <dd>9门课程</dd>
  126. </dl>
  127. </a>
  128. <a href="">
  129. <img src="https://www.php.cn/static/images/examples/ynxj.png" alt="">
  130. <dl>
  131. <dt>玉女心经</dt>
  132. <dd>5门课程</dd>
  133. </dl>
  134. </a>
  135. <a href="">
  136. <img src="https://www.php.cn/static/images/examples/tlbb.png" alt="">
  137. <dl>
  138. <dt>天龙八部</dt>
  139. <dd>3门课程</dd>
  140. </dl>
  141. </a>
  142. <a href="">
  143. <img src="https://www.php.cn/static/images/examples/phpkjkf.png" alt="">
  144. <dl>
  145. <dt>自学指南</dt>
  146. <dd>19门课程</dd>
  147. </dl>
  148. </a>
  149. <a href="">
  150. <img src="https://www.php.cn/static/images/examples/phpksrm.png" alt="">
  151. <dl>
  152. <dt>趣味闯关</dt>
  153. <dd>22门课程</dd>
  154. </dl>
  155. </a>
  156. <a href="">
  157. <div class="you">
  158. <b>&gt;</b>
  159. </div>
  160. </a>
  161. <a href="">
  162. <div class="zuo">
  163. <b>&lt;</b>
  164. </div>
  165. </a>
  166. </div>
  167. <div class="main-bottom-right">
  168. <div class="">
  169. <a href="">
  170. <img src="/220323/sp220327_183056.png">
  171. <h2>官方公众号</h2>
  172. </a>
  173. </div>
  174. <div class="">
  175. <a href="">
  176. <img src="/220323/sp220327_183108.png">
  177. <h2>官方qq群</h2>
  178. </a>
  179. </div>
  180. </div>
  181. </div>
  182. </main>
  183. </body>
  184. </html>
  1. body {
  2. background-color: #f3f5f7;
  3. }
  4. header .head {
  5. width: 100vw;
  6. display: grid;
  7. place-content: center;
  8. background-color: #343434;
  9. }
  10. header .head .top {
  11. width: 1200px;
  12. height: 40px;
  13. display: grid;
  14. grid-template-columns: 300px 100px;
  15. grid-template-rows: 40px;
  16. place-content: space-between;
  17. background-color: #343434;
  18. }
  19. header .head .top .top-left {
  20. color: #999999;
  21. font-weight: bold;
  22. padding-top:6px ;
  23. padding-left: 5px;
  24. }
  25. header .head .top .top-right {
  26. display: grid;
  27. grid-template-columns:repeat(2,1fr);
  28. place-items: center;
  29. }
  30. header .head .top .top-right .icon-tixing {
  31. color: white !important;
  32. font-size: 20px;
  33. }
  34. header .head .top .top-right img {
  35. display: flex;
  36. width: 27.22px;
  37. height: 27.22px;
  38. border:1px solid red;
  39. border-radius: 50%;
  40. }
  41. header .daohang .phpcenter .daohang-right input[type="search"] {
  42. width: 200px;
  43. height: 36px;
  44. border: none;
  45. background-color: #f7f8fa;
  46. outline: none;
  47. border-radius: 20px;
  48. }
  49. header .daohang .phpcenter .daohang-right .icon-search {
  50. font-size: 20px;
  51. font-weight: bold;
  52. color: #999999;
  53. position: relative;
  54. left: 150px;
  55. top: -26px;
  56. }
  57. /* 导航样式 */
  58. header .daohang {
  59. width: 100vw;
  60. display: grid;
  61. place-content: center;
  62. background-color: #ffffff;
  63. height: 90px;
  64. }
  65. a {
  66. text-decoration: none;
  67. color: black;
  68. }
  69. header .daohang .phpcenter {
  70. width: 1200px;
  71. height: 90px;
  72. display: grid;
  73. grid-template-columns: repeat(3,1fr);
  74. place-content: center;
  75. place-items: center;
  76. }
  77. header .daohang .phpcenter .logo {
  78. width: 140px;
  79. }
  80. header .daohang .phpcenter .daohang-right {
  81. padding-top: 20px;
  82. }
  83. header .daohang .phpcenter nav {
  84. width:825px ;
  85. display: grid;
  86. grid-template-columns:repeat(9,1fr);
  87. grid-template-rows:40px ;
  88. place-items: center;
  89. }
  90. header .daohang .phpcenter nav a h2 {
  91. font-size: 16px;
  92. font-family: "微软雅黑";
  93. color: #333;
  94. }
  95. header .daohang .phpcenter nav a {
  96. position: relative;
  97. place-content: center;
  98. line-height: 40px;
  99. }
  100. header .daohang .phpcenter nav .icon-xiajiantou {
  101. position: absolute;
  102. left: 70px;
  103. top: 3px;
  104. }
  105. header .daohang .phpcenter nav .icon-shouji {
  106. position:absolute;
  107. }
  108. header .daohang .phpcenter nav .xin {
  109. display: block;
  110. width: 22px;
  111. height: 15px;
  112. line-height: 15px;
  113. text-align: center;
  114. position:absolute;
  115. top: -2px;
  116. right: -15px;
  117. color:#ffffff;
  118. font-size: 13px;
  119. background-color: #fd5050;
  120. border-radius: 60px;
  121. }
  122. header .daohang .phpcenter nav .icon-shenglvehao{
  123. font-size: 26px;
  124. color:#6c6c6c;
  125. }
  126. header .daohang .phpcenter nav .shequ {
  127. position: absolute;
  128. top: 3px;
  129. left: 35px;
  130. }
  131. header .daohang .phpcenter nav a .appxiazai,.icon-shouji {
  132. color: red;
  133. font-size: 16px;
  134. }
  135. main .zhukuang {
  136. display: grid;
  137. grid-template-columns:166px 810px 190px ;
  138. grid-template-rows: 400px 80px;
  139. gap: 20px;
  140. place-content:center ;
  141. margin: 28px;
  142. }
  143. main .zhukuang >* {
  144. background-color: #ffffff;
  145. border-radius: 20px;
  146. }
  147. /* 左边样式 */
  148. main .zhukuang .main-left {
  149. width: 166px;
  150. height: 400px;
  151. display:grid;
  152. grid-template-rows: repeat(7,1fr);
  153. place-items: center;
  154. }
  155. main .zhukuang .main-left a:hover {
  156. background-color:#fcebed ;
  157. place-items: center;
  158. display:grid;
  159. border-radius: 20px;
  160. color: red;
  161. width: 126px;
  162. height: 40px;
  163. }
  164. /* 中间样式 */
  165. main .zhukuang .main-center img {
  166. width: 810px;
  167. height: 400px;
  168. border-radius: 20px;
  169. }
  170. /* 左下部分样式 */
  171. main .zhukuang .main-bottom-left {
  172. grid-column: span 2;
  173. display: grid;
  174. grid-template-columns: repeat(6,160px);
  175. place-content: center;
  176. place-items: center;
  177. position: relative;
  178. }
  179. main .zhukuang .main-bottom-left .bottom-left {
  180. position: ;
  181. }
  182. main .zhukuang .main-bottom-left img {
  183. width: 36px;
  184. height: 36px;
  185. margin-top: 5px;
  186. margin-left: 25px;
  187. float: left;
  188. top: -23px;
  189. right:15px;
  190. position: absolute;
  191. }
  192. main .zhukuang .main-bottom-left a {
  193. position: relative;
  194. }
  195. main .zhukuang .main-bottom-left a dl {
  196. font-size: 14px;
  197. position:absolute;
  198. width: 85px;
  199. top: -18px;
  200. left: -10px;
  201. }
  202. main .zhukuang .main-bottom-left a dl dd {
  203. font-size: 12px;
  204. color: #999999;
  205. }
  206. main .zhukuang .main-bottom-left .you {
  207. position: absolute;
  208. top: -35px;
  209. left: 865px;
  210. width: 14px;
  211. height: 29px;
  212. line-height: 29px;
  213. color: #999999;
  214. background-color: #f6f7fb;
  215. }
  216. main .zhukuang .main-bottom-left .zuo {
  217. position: absolute;
  218. top: -35px;
  219. left: -90px;
  220. width: 14px;
  221. height: 29px;
  222. line-height: 29px;
  223. color: #999999;
  224. background-color: #f6f7fb;
  225. }
  226. /* 右边样式 */
  227. main .zhukuang .main-right {
  228. display: grid;
  229. grid-template-rows: 142px 258px ;
  230. }
  231. main .zhukuang .main-right .main-right-top {
  232. display: grid;
  233. grid-template-rows: 71PX 71PX ;
  234. place-content: center;
  235. position: relative;
  236. border-bottom: 1px solid #f4f4f4;
  237. }
  238. main .zhukuang .main-right .main-right-top img {
  239. display: flex;
  240. width: 40px;
  241. height: 40px;
  242. border-radius: 50%;
  243. position: absolute;
  244. top: 15px;
  245. }
  246. main .zhukuang .main-right .main-right-top .right-top-top {
  247. width: 156px;
  248. height: 60px;
  249. }
  250. main .zhukuang .main-right .main-right-top .right-top-top .icon-tipvip {
  251. font-size: 30px;
  252. position: absolute;
  253. right: -35px;
  254. top: -5px;
  255. color:#fca62d;
  256. }
  257. main .zhukuang .main-right .main-right-top .right-top-top dl {
  258. position: absolute;
  259. right: 60px;
  260. top: 10px;
  261. }
  262. main .zhukuang .main-right .main-right-top .right-top-top a {
  263. display: block;
  264. }
  265. .right-top-bottom {
  266. margin-top: 15px;
  267. width: 150px;
  268. height: 34px;
  269. background-color:#e11717 ;
  270. color: #ffffff;
  271. text-align: center;
  272. line-height: 34px;
  273. border-radius: 20px;
  274. font-size: 14px;
  275. }
  276. /* 右下角样式 */
  277. .main-right-bottom {
  278. padding: 7px;
  279. }
  280. .main-right-bottom p {
  281. line-height: 18px;
  282. display: block;
  283. height: 18px;
  284. width: 150px;
  285. color: black;
  286. margin: 20px;
  287. font-size: 14px;
  288. font-weight: bold;
  289. }
  290. .main-right-bottom p span {
  291. margin-right: 16px;
  292. }
  293. .main-right-bottom p a {
  294. color: #999999;
  295. }
  296. .main-right-bottom .p1 {
  297. font-size: 16px;
  298. }
  299. .main-right-bottom .p1 a {
  300. background-color: #ff583d;
  301. color: #ffffff;
  302. font-size: 12px;
  303. font-weight:;
  304. }
  305. .main-bottom-right {
  306. display: grid;
  307. grid-template-columns: 95px 95px ;
  308. place-content: center;
  309. place-items: center;
  310. }
  311. .main-bottom-right img {
  312. display: block;
  313. text-align: center;
  314. margin: 0 auto;
  315. }
  316. .main-bottom-right h2 {
  317. padding-top: 5px;
  318. font-size: 14px;
  319. line-height: 20px;
  320. }
  321. * { margin: 0;
  322. padding: 0;
  323. /* box-sizing: border-box; */
  324. /* background-color:antiquewhite; */
  325. /* background-color: #f3f5f7; */
  326. /* border: 1px solid red; */
  327. font-family: "微软雅黑";
  328. }
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议