Blogger Information
Blog 13
fans 0
comment 0
visits 11167
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Grid(网格)布局-仿php中文网模块
忠于原味
Original
791 people have browsed it

使用Grid布局仿php中文网模块

废话不多说直接上代码:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <link rel="stylesheet" href="font/iconfont.css" />
  7. <title>Grid(网格)布局-仿php中文网模块</title>
  8. <style>
  9. /* 初始化 */
  10. * {
  11. margin: 0;
  12. padding: 0;
  13. box-sizing: border-box;
  14. }
  15. .container {
  16. display: grid;
  17. width: 1200px;
  18. /* 3行5列 */
  19. grid-template-columns: repeat(5, 217px);
  20. grid-template-rows: repeat(3, 176px);
  21. gap: 20px;
  22. margin: auto;
  23. }
  24. .item img {
  25. width: 217px;
  26. height: 124px;
  27. border-radius: 10px;
  28. }
  29. .item:first-of-type {
  30. grid-row-start: 1;
  31. grid-row-end: 3;
  32. }
  33. .item:first-of-type img {
  34. width: 217px;
  35. height: 372px;
  36. }
  37. a {
  38. text-decoration: none;
  39. }
  40. .item {
  41. /* 设置相对定位 */
  42. position: relative;
  43. }
  44. .font {
  45. /* 设置绝对定位 */
  46. position: absolute;
  47. top: 100px;
  48. font-size: 14px;
  49. height: 74px;
  50. width: 217px;
  51. /* 边框圆角 */
  52. border-radius: 10px;
  53. background-color: #fff;
  54. /* 盒子阴影 */
  55. box-shadow: 0px 0px 10px #888888;
  56. /* 设置鼠标悬停图标 */
  57. cursor: pointer;
  58. }
  59. .font h3 {
  60. font-size: 14px;
  61. color: #07111b;
  62. padding: 16px 0 6px;
  63. margin-left: 20px;
  64. font-weight: 400;
  65. }
  66. .font i {
  67. font-size: 12px;
  68. background-color: #93999f;
  69. color: white;
  70. margin: 2px 4px 0 0;
  71. padding: 2px;
  72. }
  73. .font div {
  74. color: #93999f;
  75. font-size: 12px;
  76. padding: 0 20px;
  77. margin-top: 10px;
  78. }
  79. .header {
  80. width: 1200px;
  81. height: 40px;
  82. font-size: 20px;
  83. font-weight: bold;
  84. color: #4d555d;
  85. margin: 40px auto 10px;
  86. /* 文字水平居中 */
  87. text-align: center;
  88. }
  89. .font-color {
  90. color: royalblue;
  91. font-size: 20px;
  92. }
  93. /* 去掉i标签斜体 */
  94. i {
  95. font-style: normal;
  96. }
  97. </style>
  98. </head>
  99. <body>
  100. <div class="header">
  101. <i class="iconfont icon-ai-code font-color"></i>php精品入门课程<i
  102. class="iconfont icon-ai-code font-color"
  103. ></i>
  104. </div>
  105. <div class="container">
  106. <div class="item">
  107. <a href=""><img src="img/1.jpg" class="img-left" alt="" /></a>
  108. </div>
  109. <div class="item">
  110. <a href=""
  111. ><img src="img/2.png" alt="" />
  112. <div class="font">
  113. <h3><i>初级</i>编程学习方法分享直播</h3>
  114. <div><span>1W+次播放</span></div>
  115. </div></a
  116. >
  117. </div>
  118. <div class="item">
  119. <a href=""
  120. ><img src="img/3.jpg" alt="" />
  121. <div class="font">
  122. <h3><i>初级</i>2018前端入门_HTML5</h3>
  123. <div><span>18W+次播放</span></div>
  124. </div></a
  125. >
  126. </div>
  127. <div class="item">
  128. <a href=""
  129. ><img src="img/4.jpg" alt="" />
  130. <div class="font">
  131. <h3><i>初级</i>CSS视频教程-玉女心经</h3>
  132. <div><span>10W+次播放</span></div>
  133. </div></a
  134. >
  135. </div>
  136. <div class="item">
  137. <a href=""
  138. ><img src="img/5.jpg" alt="" />
  139. <div class="font">
  140. <h3><i>初级</i>javaScript极速入门_玉</h3>
  141. <div><span>18W+次播放</span></div>
  142. </div></a
  143. >
  144. </div>
  145. <div class="item">
  146. <a href=""
  147. ><img src="img/6.jpg" alt="" />
  148. <div class="font">
  149. <h3><i>中级</i>独孤九贱(6)_jQuery</h3>
  150. <div><span>12W+次播放</span></div>
  151. </div></a
  152. >
  153. </div>
  154. <div class="item">
  155. <a href=""
  156. ><img src="img/7.jpeg" alt="" />
  157. <div class="font">
  158. <h3><i>初级</i>30分钟学会网页布局</h3>
  159. <div><span>6W+次播放</span></div>
  160. </div></a
  161. >
  162. </div>
  163. <div class="item">
  164. <a href=""
  165. ><img src="img/8.jpg" alt="" />
  166. <div class="font">
  167. <h3><i>初级</i>[公益直播]Web前端开发</h3>
  168. <div><span>5W+次播放</span></div>
  169. </div></a
  170. >
  171. </div>
  172. <div class="item">
  173. <a href=""
  174. ><img src="img/9.jpg" alt="" />
  175. <div class="font">
  176. <h3><i>初级</i>phpStudy极速入门视频</h3>
  177. <div><span>40W+次播放</span></div>
  178. </div></a
  179. >
  180. </div>
  181. <div class="item">
  182. <a href=""
  183. ><img src="img/10.jpg" alt="" />
  184. <div class="font">
  185. <h3><i>中级</i>ThinkPHP6.0极速入门</h3>
  186. <div><span>4W+次播放</span></div>
  187. </div></a
  188. >
  189. </div>
  190. <div class="item">
  191. <a href=""
  192. ><img src="img/11.jpg" alt="" />
  193. <div class="font">
  194. <h3><i>中级</i>独孤九贱(4)_PHP视频</h3>
  195. <div><span>50W+次播放</span></div>
  196. </div></a
  197. >
  198. </div>
  199. <div class="item">
  200. <a href=""
  201. ><img src="img/12.jpg" alt="" />
  202. <div class="font">
  203. <h3><i>中级</i>php完全自学手册</h3>
  204. <div><span>20W+次播放</span></div>
  205. </div></a
  206. >
  207. </div>
  208. <div class="item">
  209. <a href=""
  210. ><img src="img/13.jpg" alt="" />
  211. <div class="font">
  212. <h3><i>中级</i>MySQL权威开发指南</h3>
  213. <div><span>2W+次播放</span></div>
  214. </div></a
  215. >
  216. </div>
  217. <div class="item">
  218. <a href=""
  219. ><img src="img/14.jpg" alt="" />
  220. <div class="font">
  221. <h3><i>中级</i>[公益直播]PHP实战开播</h3>
  222. <div><span>3W+次播放</span></div>
  223. </div></a
  224. >
  225. </div>
  226. </div>
  227. </body>
  228. </html>

效果图:

ps:这个grid网格布局用起来真是太爽了,不过属性相比FlexBox布局的属性多了不少,多去熟悉它的属性,运用它,相信大家都会进步的更快,布局起来更爽!

Correcting teacher:天蓬老师天蓬老师

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