博客列表 >grid布局仿PHP中文网课程列表

grid布局仿PHP中文网课程列表

知行合一
知行合一原创
2020年07月03日 10:50:50518浏览

新学Grid布局,仿制了PHP中文网的课程列表。

效果图

代码如下

  1. <html lang="en">
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  5. <title>Document</title>
  6. <style>
  7. * {
  8. margin: 0;
  9. padding: 0;
  10. box-sizing: border-box;
  11. font-size: 14px;
  12. color: #666;
  13. }
  14. a {
  15. text-decoration: none;
  16. }
  17. ul {
  18. list-style: none;
  19. }
  20. img {
  21. border: none;
  22. }
  23. .container {
  24. margin: 50px auto;
  25. width: 1200px;
  26. height: 570px;
  27. display: grid;
  28. grid-template-columns: repeat(5, 1fr);
  29. grid-template-rows: repeat(3, 1fr);
  30. }
  31. li {
  32. border-radius: 5%;
  33. box-shadow: 0 0 10px #888;
  34. position: relative;
  35. width: 217px;
  36. height: 166px;
  37. place-self: start center;
  38. }
  39. li img {
  40. width: 100%;
  41. border-radius: 5%;
  42. }
  43. li>a {
  44. position: absolute;
  45. display: block;
  46. }
  47. .title {
  48. position: absolute;
  49. bottom: 30px;
  50. left: 0;
  51. height: 60px;
  52. background-color: white;
  53. padding-left: 20px;
  54. z-index: 9;
  55. width: 100%;
  56. padding-top: 10px;
  57. border-radius: 8px;
  58. }
  59. .title:hover {
  60. height: 100px;
  61. transition: height 0.7s;/*动画效果*/
  62. }
  63. .title span {
  64. padding: 2px;
  65. font-style: normal;
  66. font-size: 12px;
  67. color: #fff;
  68. line-height: 12px;
  69. border-radius: 1px;
  70. background-color: #93999f;
  71. display: inline-block;
  72. margin-right: 3px;
  73. }
  74. .click {
  75. position: absolute;
  76. bottom: 0;
  77. left: 0;
  78. height: 30px;
  79. padding-left: 20px;
  80. width: 100%;
  81. }
  82. li:first-of-type {
  83. grid-row: 1/span 2;
  84. height: 362px;
  85. }
  86. </style>
  87. </head>
  88. <body>
  89. <ul class="container">
  90. <li><img src="images/gridcase/1.jpg"></li>
  91. <li><a href=""><img src="images/gridcase/2.png"></a>
  92. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  93. <div class="click">1W+次播放</div>
  94. </li>
  95. <li><a href=""><img src="images/gridcase/2.png"></a>
  96. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  97. <div class="click">1W+次播放</div>
  98. </li>
  99. <li><a href=""><img src="images/gridcase/2.png"></a>
  100. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  101. <div class="click">1W+次播放</div>
  102. </li>
  103. <li><a href=""><img src="images/gridcase/2.png"></a>
  104. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  105. <div class="click">1W+次播放</div>
  106. </li>
  107. <li><a href=""><img src="images/gridcase/2.png"></a>
  108. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  109. <div class="click">1W+次播放</div>
  110. </li>
  111. <li><a href=""><img src="images/gridcase/2.png"></a>
  112. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  113. <div class="click">1W+次播放</div>
  114. </li>
  115. <li><a href=""><img src="images/gridcase/2.png"></a>
  116. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  117. <div class="click">1W+次播放</div>
  118. </li>
  119. <li><a href=""><img src="images/gridcase/2.png"></a>
  120. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  121. <div class="click">1W+次播放</div>
  122. </li>
  123. <li><a href=""><img src="images/gridcase/2.png"></a>
  124. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  125. <div class="click">1W+次播放</div>
  126. </li>
  127. <li><a href=""><img src="images/gridcase/2.png"></a>
  128. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  129. <div class="click">1W+次播放</div>
  130. </li>
  131. <li><a href=""><img src="images/gridcase/2.png"></a>
  132. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  133. <div class="click">1W+次播放</div>
  134. </li>
  135. <li><a href=""><img src="images/gridcase/2.png"></a>
  136. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  137. <div class="click">1W+次播放</div>
  138. </li>
  139. <li><a href=""><img src="images/gridcase/2.png"></a>
  140. <div class="title"><span>初级</span><a href="">编程学习方法分享直播公益课</a></div>
  141. <div class="click">1W+次播放</div>
  142. </li>
  143. </ul>
  144. </body>
  145. </html>

总结

gird布局是新兴布局方式,适合于多行多列布局,很强大。相关知识点很多,需要做好笔记,多加练习,才能熟记在心。

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