博客列表 >grid布局实现PHP中文网的一个版块(0628)

grid布局实现PHP中文网的一个版块(0628)

丶久而旧之丶
丶久而旧之丶原创
2020年07月09日 22:20:37613浏览

  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. <title>grid布局</title>
  7. <link rel="stylesheet" href="font.css" />
  8. <style>
  9. /* 样式初始化 */
  10. * {
  11. padding: 0;
  12. margin: 0;
  13. box-sizing: border-box;
  14. font-size: 14px;
  15. }
  16. /* 设置整体盒子的宽高 */
  17. .header {
  18. width: 1200px;
  19. height: 646.5px;
  20. margin: auto;
  21. }
  22. /* 设置grid布局,宽高和几行几列 */
  23. .container {
  24. width: 1200px;
  25. height: 576px;
  26. display: grid;
  27. grid-template-columns: repeat(5, 1fr);
  28. grid-template-rows: repeat(3, 1fr);
  29. place-items: start center;
  30. }
  31. /* 设置标题的字体大小和外边距,水平居中 */
  32. .tittle {
  33. text-align: center;
  34. margin: 20px 0;
  35. font-size: 23px;
  36. }
  37. /* 设置图标的样式 */
  38. .tittle > .iconfont {
  39. color: royalblue;
  40. font-size: 1.4rem;
  41. }
  42. /* 设置单元格的大小 */
  43. .container > .item {
  44. width: 217px;
  45. height: 166px;
  46. }
  47. /* 设置第一个单元格跨两行 */
  48. .container > .item:first-of-type {
  49. grid-row: span 2;
  50. }
  51. /* 设置单元格圆角和阴影 */
  52. .container > .item {
  53. border-radius: 8px;
  54. box-shadow: 3px 3px 7px lightgray;
  55. }
  56. /* 设置图片的圆角和大小 */
  57. .container > .item img {
  58. border-radius: 8px;
  59. width: 100%;
  60. }
  61. /* 设置a标签的样式 */
  62. .item a {
  63. text-decoration: none;
  64. color: black;
  65. }
  66. /* 设置教程详情块的样式 */
  67. .container > .item > .item1 {
  68. display: grid;
  69. place-content: space-between;
  70. min-height: 85px;
  71. background-color: white;
  72. border-radius: 8px;
  73. padding: 10px;
  74. position: relative;
  75. top: -43px;
  76. }
  77. /* 设置教程详情块鼠标悬停时的效果向上推动 */
  78. .container > .item > .item1:hover {
  79. min-height: 120px;
  80. cursor: pointer;
  81. position: relative;
  82. top: -78px;
  83. transition: top 0.1s;
  84. }
  85. /* 设置教程详情块中的字体样式 */
  86. .container > .item > .item1 > a > span {
  87. color: mintcream;
  88. background-color: lightslategray;
  89. border-radius: 3px;
  90. margin: 8px;
  91. }
  92. /* 设置播放次数的字体样式 */
  93. .container > .item > .item1 > span {
  94. color: rgba(92, 92, 100, 0.493);
  95. margin: 0 8px;
  96. }
  97. </style>
  98. </head>
  99. <body>
  100. <div class="header">
  101. <h3 class="tittle">
  102. <span class="iconfont">&#xe70b;</span>PHP入门精品教程<span
  103. class="iconfont"
  104. >&#xe70b;</span
  105. >
  106. </h3>
  107. <div class="container">
  108. <div class="item">
  109. <a href=""><img src="tu/01.jpg" /></a>
  110. </div>
  111. <div class="item">
  112. <a href=""><img src="tu/02.png" alt="" /> </a>
  113. <div class="item1">
  114. <a href=""><span>初级</span>编程学习方法分享直播</a>
  115. <span>1W+次播放</span>
  116. </div>
  117. </div>
  118. <div class="item">
  119. <a href=""><img src="tu/03.jpg" alt="" /> </a>
  120. <div class="item1">
  121. <a href=""><span>初级</span>2018前端入门_HTML5</a>
  122. <span>18W+次播放</span>
  123. </div>
  124. </div>
  125. <div class="item">
  126. <a href=""><img src="tu/04.jpg" alt="" /> </a>
  127. <div class="item1">
  128. <a href=""><span>初级</span>CSS视频教程-玉女心经</a>
  129. <span>10W+次播放</span>
  130. </div>
  131. </div>
  132. <div class="item">
  133. <a href=""><img src="tu/05.jpg" alt="" /> </a>
  134. <div class="item1">
  135. <a href=""><span>初级</span>JavaScript极速入门_玉女心经系列</a>
  136. <span>18W+次播放</span>
  137. </div>
  138. </div>
  139. <div class="item">
  140. <a href=""><img src="tu/06.jpg" alt="" /> </a>
  141. <div class="item1">
  142. <a href=""><span>中级</span>独孤九贱(6)_JQuery视频教程</a>
  143. <span>12W+次播放</span>
  144. </div>
  145. </div>
  146. <div class="item">
  147. <a href=""><img src="tu/07.jpg" alt="" /> </a>
  148. <div class="item1">
  149. <a href=""><span>初级</span>30分钟学会网站布局</a>
  150. <span>6W+次播放</span>
  151. </div>
  152. </div>
  153. <div class="item">
  154. <a href=""><img src="tu/08.jpg" alt="" /> </a>
  155. <div class="item1">
  156. <a href=""><span>初级</span>[公益直播]Web前端开发极速入门</a>
  157. <span>5W+次播放</span>
  158. </div>
  159. </div>
  160. <div class="item">
  161. <a href=""><img src="tu/09.jpg" alt="" /> </a>
  162. <div class="item1">
  163. <a href=""><span>初级</span>PHPStudy极速入门视频</a>
  164. <span>40W+次播放</span>
  165. </div>
  166. </div>
  167. <div class="item">
  168. <a href=""><img src="tu/10.jpg" alt="" /> </a>
  169. <div class="item1">
  170. <a href=""><span>中级</span>ThinkPHP6.0极速入门</a>
  171. <span>4W+次播放</span>
  172. </div>
  173. </div>
  174. <div class="item">
  175. <a href=""><img src="tu/11.jpg" alt="" /> </a>
  176. <div class="item1">
  177. <a href=""><span>中级</span>独孤九贱(4)_PHP视频</a>
  178. <span>50W+次播放</span>
  179. </div>
  180. </div>
  181. <div class="item">
  182. <a href=""><img src="tu/12.jpg" alt="" /> </a>
  183. <div class="item1">
  184. <a href=""><span>初级</span>PHP完全自学手册</a>
  185. <span>20W+次播放</span>
  186. </div>
  187. </div>
  188. <div class="item">
  189. <a href=""><img src="tu/13.jpg" alt="" /> </a>
  190. <div class="item1">
  191. <a href=""><span>初级</span>MySQL权威开发指南</a>
  192. <span>2W+次播放</span>
  193. </div>
  194. </div>
  195. <div class="item">
  196. <a href=""><img src="tu/14.jpg" alt="" /> </a>
  197. <div class="item1">
  198. <a href=""><span>中级</span>[公益直播]PHP实战开发极速入门</a>
  199. <span>3W+次播放</span>
  200. </div>
  201. </div>
  202. </div>
  203. </div>
  204. </body>
  205. </html>

总结

1.对于grid的排列方式要熟记,多做练习
2.开始没看老师的详解时自己写的代码太过于冗余了,还是需要多进行操作,加强对代码的理解。

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